Module:Sort list: Difference between revisions
Appearance
Content deleted Content added
use lambda for revcomp |
|||
Line 9: | Line 9: | ||
function p.desc(frame) |
function p.desc(frame) |
||
items = splitLine( frame.args[1] ); |
items = splitLine( frame.args[1] ); |
||
table.sort( items, |
table.sort( items, function (a, b) return a > b end ); |
||
return table.concat( items, "\n" ); |
return table.concat( items, "\n" ); |
||
end |
end |
||
Line 17: | Line 17: | ||
end |
end |
||
function revComp( a, b ) |
|||
return a > b; |
|||
end |
|||
return p |
return p |
Revision as of 00:50, 13 April 2016
A sorting module, intended to be used with {{sort list}}.
See also
local p = {}
function p.asc(frame)
items = splitLine( frame.args[1] );
table.sort( items );
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 splitLine( text )
return mw.text.split( text, "\n", true );
end
return p