Module:collation: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
 
Line 7: Line 7:
local get_plaintext = require("Module:utilities").get_plaintext
local get_plaintext = require("Module:utilities").get_plaintext
local match = string.match
local match = string.match
local memoize = require("Module:fun").memoize
local memoize = require("Module:memoize")
local remove = table.remove
local remove = table.remove
local sort = table.sort
local sort = table.sort
Line 91: Line 91:
-- begin with the bytes 240 to 244.
-- begin with the bytes 240 to 244.
do
do
-- Memoize match because we've set the `simple` flag, which means it
-- Memoize match with the `simple` flag, which means it should only be used
-- should only be used with fixed additional arguments (in this case, the
-- with fixed additional arguments (in this case, the pattern).
-- pattern).
local sortkey_match = memoize(match, true)
local match = memoize(match, true)
function export.string_sort(item1, item2)
function export.string_sort(item1, item2)
if match(item1, "^[^\240-\244]*$") and match(item2, "^[^\240-\244]*$") then
if sortkey_match(item1, "^[^\240-\244]*$") and sortkey_match(item2, "^[^\240-\244]*$") then
return item1 < item2
return item1 < item2
end
end
Line 139: Line 138:
local m_table = require("Module:table")
local m_table = require("Module:table")
local elems = m_table.shallowcopy(args)
local elems = m_table.shallowCopy(args)
local m_languages = require("Module:languages")
local m_languages = require("Module:languages")
local lang
local lang

Navigation menu