local export = {}
local u = mw.ustring.char
local a, b = u(0xF000), u(0xF001)
local remove_diacritics = u(0x0300) .. u(0x0301) -- grave, acute
local oneChar = {
["ɪ"] = "i" .. a, ["ì"] = "i" .. b, ["í"] = "i" .. b, ["ʊ"] = "u" .. a, ["ù"] = "u" .. b, ["ú"] = "u" .. b
}
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 .. "]", ""))) -- decompose, remove appropriate diacritics, then recompose again
end
return export