Hi. I cannot find a way of sorting a table containing French or German strings using table.sort( with or without a comparison function).
From the official Lua.org site: " Lua compares strings in alphabetical order, which follows the locale set for Lua". The locale seems to be set to English and I see no way to specify which locale I want.
How can I set the locale for sorting?
Example
local p = {}
function p.sortfr(frame)
local tablefr = { -- In the correct order
"aperçu",
"déception",
"déçu",
"épicentre",
"étonnament",
"mæstro",
"mais",
"maïs",
"maligne",
"odomètre",
"œillère",
"oléoduc"
}
table.sort(tablefr)
mw.logObject(tablefr) -- Wrong result
table.sort(tablefr, function (m,n) return mw.ustring.lower(m) < mw.ustring.lower(n) end )
return mw.dumpObject(tablefr) -- Also wrong
end
return p
Result
table#1 { "aperçu", "déception", "déçu", "mais", "maligne", "maïs", "mæstro", "odomètre", "oléoduc", "épicentre", "étonnament", "œillère", }