Jump to content

Module:Sort list: Difference between revisions

From Wikipedia, the free encyclopedia
use lambda for revcomp
m Pppery moved page Module:Sort to Module:Sort list without leaving a redirect: Make module name match template name
(No difference)

Revision as of 22:44, 31 July 2019

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