Module:Laoo-sortkey
පෙනුම
- පහත දැක්වෙන උපදෙස්, Module:Laoo-sortkey/documentation හි පිහිටා ඇත. Module:Laoo-sortkey/documentation]]. [සංස්කරණය] Categories were auto-generated by Module:module categorization. [edit]
- ප්රයෝජනවත් සබැඳි: උප පිටු ලැයිස්තුව • සබැඳි • transclusions • testcases • sandbox
This module will sort text in the Lao අක්ෂරක්රමය. It is used to sort Eastern Bru, Western Bru, Khmu, සහ ලාඕ.
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:Laoo-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 m_str_utils = require("Module:string utilities")
local gmatch = m_str_utils.gmatch
local gsub = m_str_utils.gsub
local u = m_str_utils.char
local a = u(0xF000)
local minorMarkSet = "([" .. u(0xEC8) .. "-" .. u(0xECE) .. "])"
local minorMarks = {
[u(0xEC8)] = "1", [u(0xEC9)] = "2", [u(0xECA)] = "3", [u(0xECB)] = "4", [u(0xECC)] = "5", [u(0xECD)] = "6", [u(0xECE)] = "7"
}
local monographs = {
["[%pໆ]"] = "", ["ຼ"] = "ລ" .. a, ["ຽ"] = "ຍ" .. a, ["ໜ"] = "ຫນ" .. a, ["ໝ"] = "ຫມ" .. a
}
function export.makeSortKey(text, lang, sc)
local minorKey = ""
for mark in gmatch(text, minorMarkSet) do
minorKey = minorKey .. minorMarks[mark]
end
text = gsub(text, minorMarkSet, "")
for from, to in pairs(monographs) do
text = gsub(text, from, to)
end
text = gsub(text, "([ເແໂໃໄ])([ກ-ຮໞໟ])", "%2%1")
return text .. minorKey
end
-- compare between Lao texts
function export.string_compare(item1, item2)
return export.makeSortKey(item1) < export.makeSortKey(item2)
end
return export