Module:User:Theknightwho/lua-uca

Hello, you have come here looking for the meaning of the word Module:User:Theknightwho/lua-uca. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Theknightwho/lua-uca, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Theknightwho/lua-uca in singular and plural. Everything you need to know about the word Module:User:Theknightwho/lua-uca you have here. The definition of the word Module:User:Theknightwho/lua-uca will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Theknightwho/lua-uca, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

function export.makeSortKey(text)
	local data = mw.loadData("Module:User:Theknightwho/lua-uca/lua-uca-ducet/Latn")
	local collator = require "Module:User:Theknightwho/lua-uca/lua-uca-collator"
	--local languages = require "Module:User:Theknightwho/lua-uca/lua-uca-languages"
	local collatorObj = collator.new(data)
	--collatorObj = languages.en(collatorObj)

	text = mw.ustring.toNFD(mw.ustring.upper(text))
	local char = mw.ustring.char
	local codepoints = data
	local weightedSortkey = collatorObj:make_sort_key({mw.ustring.codepoint(text, 1, mw.ustring.len(text))}, 1)
	
	rawset(data, 1, nil)
	
	local sortkey = {}
	local j, tail
	for i, weight in ipairs(weightedSortkey) do
		if weight == 0 then tail = true end
		if codepoints and not tail then
			table.insert(sortkey, char(codepoints))
		elseif not tail then
			j = 0
			while not codepoints and weight-j > 0 do
				j = j + 1
				if codepoints then
					table.insert(sortkey, char(codepoints) .. char(0xF000+j-1))
				end
			end
		elseif weight > 0 then
			table.insert(sortkey, char(0xF000+weight))
		end
	end
	
	return table.concat(sortkey)
	--return weightedSortkey
end

function export.sort(terms)
	local data = mw.loadData("Module:User:Theknightwho/lua-uca/lua-uca-ducet/Latn")
	local collator = require "Module:User:Theknightwho/lua-uca/lua-uca-collator"
	--local languages = require "Module:User:Theknightwho/lua-uca/lua-uca-languages"
	local collatorObj = collator.new(data)
	--collatorObj = languages.en(collatorObj)
	
	table.sort(terms, function(a, b) 
		return collatorObj:compare_strings(a, b) 
	end)
	
	return terms
end

return export