local icu = require("justenoughicu")
local collatedSort = {
und = function (t, _)
table.sort(t)
end,
}
setmetatable(collatedSort, {
__call = function (self, t, options)
local lang = SILE.settings:get("document.language")
if self[lang] and type(self[lang]) == "function" then
return self[lang](t, options)
end
if self[lang] and type(self[lang]) == "table" then
options = options or self[lang]
end
local collator = icu.collation_create(lang, options or {})
table.sort(t, function (s1, s2)
return icu.compare(collator, s1, s2)
end)
icu.collation_destroy(collator)
end,
})
return collatedSort