This module will sort text in the Lao script. It is used to sort Eastern Bru, Western Bru, Khmu, and Lao.
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.
makeSortKey(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.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 = "()"
local minorMarks = {
= "1", = "2", = "3", = "4", = "5", = "6", = "7"
}
local monographs = {
"] = "", = "ລ" .. a, = "ຍ" .. a, = "ຫນ" .. a, = "ຫມ" .. a
}
function export.makeSortKey(text, lang, sc)
local minorKey = ""
for mark in gmatch(text, minorMarkSet) do
minorKey = minorKey .. minorMarks
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