Modulus:listSort
Appearance
Usus
[+/-]Usurpatur in “Formula:ordinatio”
{{#invoke:listSort|{{{1}}}|{{{2}}}}}
local p = {}
function p.asc(frame)
items = splitLine( frame.args[1] );
table.sort( items );
return table.concat( items, "\n" );
end
function p.trans(frame)
items = splitLine( frame.args[1] );
table.sort( items, function (a, b) return transMatch(a, b) end );
return table.concat( items, "\n" );
end
function p.desc(frame)
items = splitLine( frame.args[1] );
table.sort( items, function (a, b) return a > b end );
return table.concat( items, "\n" );
end
function p.pre(frame)
return "<pre>" .. frame.args[1] .. "</pre>";
end
function p.perm(frame)
items = splitLine( frame.args[1] );
return "<pre>" .. table.concat( items, "\n" ) .. "</pre>";
end
function splitLine( text )
return mw.text.split( text, "\n", true );
end
function transMatch( string1, string2 )
local match = "%W*%w+%s*%w*%s*%w*%s*:";
local capture1 = mw.ustring.match(string1, match);
local capture2 = mw.ustring.match(string2, match);
return capture1 < capture2;
end
return p