Jump to content

Module:Sort list

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MZMcBride (talk | contribs) at 18:55, 27 December 2015 (new module; content from m:Module:Sort (m:Special:Permalink/5541934)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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, revComp );
    return table.concat( items, "\n" );
end

function splitLine( text )
    return mw.text.split( text, "\n", true );    
end

function revComp( a, b )
    return a > b;
end

return p