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 11:07, 9 June 2020 (Attempt to remove newlines before adding our own <br>s). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

function p.asc(frame)
    list = {}
	for key,value in pairs(frame.args) do
		-- Remove newlines
		stripped = string.gsub(value, "n", "")
		table.insert(list, stripped)
	end
    table.sort( list )
    return table.concat( list, "<br>" )
end

function p.desc(frame)
	list = {}
	for key,value in pairs(frame.args) do
		-- Remove newlines
		stripped = string.gsub(value, "n", "")
		table.insert(list, stripped)
	end
    table.sort( list, function (a, b) return a > b end )
    return table.concat( list, "<br>" )
end

return p