local export = {}
local u = mw.ustring.char
local a, b, c, d, e, f, g, h, i, j, k, l, m, n, o = u(0xF000), u(0xF001), u(0xF002), u(0xF003), u(0xF004), u(0xF005), u(0xF006), u(0xF007), u(0xF008), u(0xF009), u(0xF00A), u(0xF00B), u(0xF00C), u(0xF00D), u(0xF00E)
local oneChar = {
= "г" .. c, = "г" .. d, = "е" .. a, = "з" .. b, = "з" .. d, = "к" .. c, = "к" .. f, = "к" .. k, = "л" .. a, = "п" .. b, = "п" .. c, = "с" .. b, = "т" .. b, = "х" .. e, = "ц" .. d, = "ч" .. a, = "ч" .. b, = "ч" .. c, = "ы" .. a, = "ы" .. b, = "ь" .. a
}
local twoChars = {
= "б" .. a, = "в" .. a, = "г" .. a, = "г" .. b, = "г" .. e, = "г" .. f, = "г" .. g, = "г" .. h, = "г" .. i, = "г" .. j, = "д" .. a, = "ж" .. a, = "ж" .. b, = "з" .. a, = "з" .. c, = "з" .. e, = "з" .. f, = "з" .. g, = "к" .. a, = "к" .. b, = "к" .. d, = "к" .. e, = "к" .. g, = "к" .. h, = "к" .. i, = "к" .. l, = "к" .. m, = "к" .. n, = "л" .. b, = "м" .. a, = "п" .. a, = "п" .. d, = "п" .. e, = "с" .. a, = "с" .. c, = "т" .. a, = "т" .. c, = "ф" .. a, = "х" .. a, = "х" .. b, = "х" .. c, = "х" .. f, = "ц" .. a, = "ц" .. b, = "ц" .. c, = "ц" .. e, = "ц" .. f, = "ц" .. g, = "ш" .. a, = "ш" .. b, = "ы" .. c
}
local threeChars = {
= "г" .. k, = "г" .. l, = "к" .. j, = "к" .. o, = "х" .. d
}
function export.makeSortKey(text, lang, sc)
text = mw.ustring.lower(text)
for from, to in pairs(threeChars) do
text = mw.ustring.gsub(text, from, to)
end
for from, to in pairs(twoChars) do
text = mw.ustring.gsub(text, from, to)
end
return mw.ustring.upper(mw.ustring.gsub(text, ".", oneChar))
end
return export