Module:Sandbox/Jackmcbarn
Appearance
Lua error in mw.text.lua at line 25: bad argument #1 to 'match' (string expected, got nil).
local p = {}
local function split(str, delim)
local retval, endpos = {}, 1
for elem, pos in str:gmatch('(.-)' .. delim .. '()') do
table.insert(retval, elem)
endpos = pos
end
table.insert(retval, str:sub(endpos))
return retval
end
function p.main(frame)
local list = mw.text.trim(frame.args[1])
local listEntries = split(list, '\n')
table.sort(listEntries, function(a,b)
return split(a, ' ')[2]< split(b, ' ')[2]
end)
return table.concat(listEntries, '\n')
end
return p