Module:sms-sortkey

Revision as of 09:38, 27 April 2024 by wikt>SurjectionBot (Protected "Module:sms-sortkey": (bot) automatically protect highly visible templates/modules (reference score: 1253+ >= 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:sms-sortkey/doc

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

local oneChar = {
	["â"] = "a" .. a, ["č"] = "c" .. a, ["ʒ"] = "c" .. b, ["ǯ"] = "c" .. c, ["đ"] = "d" .. a, ["ǧ"] = "g" .. a, ["ǥ"] = "g" .. b, ["ǩ"] = "k" .. a, ["ŋ"] = "n" .. a, ["õ"] = "o" .. a, ["š"] = "s" .. a, ["ž"] = "z" .. a, ["å"] = "z" .. b, ["ä"] = "z" .. c
}

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

return export