Jump to content

Module:Sorted plain list

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Frietjes (talk | contribs) at 12:49, 18 September 2016 (better to have that in a different module). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- This module generates a sorted plain list
-- It was created as a modification of [[Module:Sort]]
local p = {}

function p.asc(frame)
    items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true)
    table.sort( items )
    return '<div class="plainlist"><ul><li>' .. table.concat( items, "</li><li>" ) .. '</li></ul></div>'
end

function p.desc(frame)
    items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true)
    table.sort( items, function (a, b) return a > b end )
    return '<div class="plainlist"><ul><li>' .. table.concat( items, "</li><li>" ) .. '</li></ul></div>'
end

return p