Module:Grek-sortkey

local export = {} local u = mw.ustring.char

remove_diacritics = u(0x0300) .. u(0x0301) .. u(0x0308) .. u(0x030C) .. u(0x0313) .. u(0x0314) .. u(0x0342) .. u(0x0345) -- varia, tonos, dialytika, caron, psili, dasia, perispomeni, ypogegrammeni

local oneChar = { ["ς"] = "σ" }

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