This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

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 minorMarkSet = "([" .. u(0xE47) .. "-" .. u(0xE4E) .. u(0x302) .. u(0x304) .. u(0x331) .. "])"

local minorMarks = {
	[u(0xE47)] = "0", [u(0xE48)] = "1", [u(0xE49)] = "2", [u(0xE4A)] = "3", [u(0xE4B)] = "4",
	[u(0xE4C)] = "5", [u(0xE4D)] = "6", [u(0xE4E)] = "7", [u(0x302)] = "8", [u(0x304)] = "9", [u(0x331)] = "A"
}

function export.makeSortKey(text, lang, sc)
	local minorKey = ""
	for mark in gmatch(text, minorMarkSet) do
		minorKey = minorKey .. minorMarks[mark]
	end
	text = gsub(text, minorMarkSet, "")
	
	text = gsub(text, "[%pๆ]", "")
	text = gsub(text, "([เแโใไ])(ʼ?[ก-ฮ])", "%2%1")
	
	return text .. minorKey
end

return export
"https://si.wiktionary.org/w/index.php?title=Module:Thai-sortkey&oldid=195785" වෙතින් සම්ප්‍රවේශනය කෙරිණි