Module:ulc-sortkey
Appearance
- The following documentation is located at Module:ulc-sortkey/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will sort Ulch language text.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{sortkey}}.
Within a module, use Module:languages#Language:makeSortKey.
For testcases, see Module:ulc-sortkey/testcases.
Functions
makeSortKey(text, lang, sc)- Generates a sortkey for a given piece of
textwritten in the script specified by the codesc, and language specified by the codelang. - When the sort fails, returns
nil.
local export = {}
local u = mw.ustring.char
local a, b = u(0xF000), u(0xF001)
local oneChar = {
["ё"] = "е" .. a, ["ӈ"] = "н" .. b
}
local twoChars = {
["дʼ"] = "д" .. a, ["нʼ"] = "н" .. a
}
function export.makeSortKey(text, lang, sc)
text = mw.ustring.lower(text)
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