Jump to content

Module:Infobox sort

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Brooklynpedestrian (talk | contribs) at 10:10, 9 June 2020 (Created page with 'local p = {} function p.asc(frame) items = splitLine( frame.args[1] ); table.sort( items ); return table.concat( items, "<br>" ); end function...'). 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, "<br>" );    
end

function p.desc(frame)
    items = splitLine( frame.args[1] );
    table.sort( items, function (a, b) return a > b end );
    return table.concat( items, "<br>" );
end

function splitLine( text )
    return mw.text.split( text, "%s" );    
end



return p