Module:Sort
Appearance
This module sorts a list of items separates by pipes. After the f (not one of the items) a separator is specified (for the pipe write {{!}}).
Example:
{{#invoke:Sort|f|, |g|p|hi|d|h}}
gives:
d, g, h, hi, p
{{#invoke:Sort|f|{{!}}|g|p|hi|d|h}}
gives:
d|g|h|hi|p
This module is referenced by Help:Sorting.
local p = {}
function p.f(frame)
local t = {}
local delim = frame.args[1]
-- This adds all arguments, including named parameters,
-- in an unspecified order, but fields for consecutive values
-- starting at 1 will probably be in numerical order.
for n, v in pairs(frame.args) do table.insert(t, v) end
table.remove(t, 1)
table.sort(t)
return table.concat(t, delim)
end
return p