Module:sort list

From Linguifex
Revision as of 15:10, 1 October 2021 by Nicomega (talk | contribs) (Created page with "local p = {} function p.asc(frame) items = splitLine( frame.args[1] ); table.sort( items ); return table.concat( items, "\n" ); end function p.desc(frame)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:sort list/doc

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