Module:Sort list
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Sort list/doc
Code
local p = {}
function p.asc(frame)
items = splitLine( frame.args[1] );
table.sort( items, function (a, b) return rep(a) < rep(b) end );
return table.concat( items, "\n" );
end
function p.desc(frame)
items = splitLine( frame.args[1] );
table.sort( items, function (a, b) return rep(a) > rep(b) end );
return table.concat( items, "\n" );
end
function splitLine( text )
return mw.text.split( text, "\n", true );
end
function rep( text )
return mw.ustring.lower(mw.ustring.gsub(text, "%[%[.+|(.+)%]%]", "%1"))
end
return p