Module:smj-sortkey

Revision as of 09:38, 27 April 2024 by wikt>SurjectionBot (Protected "Module:smj-sortkey": (bot) automatically protect highly visible templates/modules (reference score: 1899+ >= 1000) ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:smj-sortkey/doc

local export = {}
local u = mw.ustring.char
local a, b = u(0xF000), u(0xF001)

local oneChar = {
	["á"] = "a" .. a, ["ŋ"] = "n" .. a, ["ń"] = "n" .. a, ["ñ"] = "n" .. a, ["å"] = "z" .. a, ["æ"] = "z" .. b, ["ä"] = "z" .. b
}

function export.makeSortKey(text, lang, sc)
	return mw.ustring.upper(mw.ustring.gsub(mw.ustring.lower(text), ".", oneChar))
end

return export