Module:tzl-sortkey

local export = {} local u = mw.ustring.char local a = u(0xF000)

local remove_diacritics = u(0x0300) .. "-" .. u(0x0303) .. u(0x0308) .. u(0x030A) .. u(0x0327) -- grave, acute, circumflex, tilde, diaeresis, ring above, cedilla

local oneChar = { ["ð"] = "d" .. a, ["ß"] = "ss", ["þ"] = "z" .. a }

function export.makeSortKey(text, lang, sc) return mw.ustring.upper(mw.ustring.toNFC(mw.ustring.gsub(mw.ustring.toNFD(mw.ustring.gsub(mw.ustring.lower(text), ".", oneChar)), "[" .. remove_diacritics .. "]", ""))) end

return export