Module:Infobox sort
Appearance
local p = {}
function p.asc(frame)
list = {}
for key,value in pairs(frame.args) do
-- Remove newlines
stripped = string.gsub(value, "\n", "")
stripped = string.gsub(value, "\r", "")
if stripped ~= nil and stripped ~= "" and stripped ~= "\n" and stripped ~= " " and stripped ~= "\r" then
table.insert(list, stripped)
end
end
table.sort( list )
return table.concat( list, "<br>" )
end
function p.desc(frame)
list = {}
for key,value in pairs(frame.args) do
mw.log("Before processing")
mw.logObject(value)
-- Remove newlines
stripped = string.gsub(value, "\n", "")
if stripped ~= nil and stripped ~= "" and stripped ~= "\n" and stripped ~= "%s" then
mw.log("Processed")
mw.logObject(stripped)
table.insert(list, stripped)
end
end
table.sort( list, function (a, b) return a > b end )
return table.concat( list, "<br>" )
end
return p