Module:bnt-com-sortkey: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Use faster implementation of mw.ustring.char.
 
m 1 revision imported
 
(No difference)

Latest revision as of 12:00, 21 April 2026



local export = {}
local u = require("Module:string/char")
local a = u(0xF000)

local oneChar = {
	["ɓ"] = "b" .. a, ["ɗ"] = "d" .. a
}

local twoChars = {
	["v̄"] = "v" .. 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