Module:Template invocation: Difference between revisions
m
sort parameters alphabetically instead of returning them in random order
(allow this to work for numbers) |
m (sort parameters alphabetically instead of returning them in random order) |
||
Line 101: | Line 101: | ||
invArgs[k] = nil -- Erase the key so that we don't add the value twice | invArgs[k] = nil -- Erase the key so that we don't add the value twice | ||
end | end | ||
local invArgs_list = {} -- sort a parameter list; preferable to randomly sorted output | |||
for k, v in pairs(invArgs) do | for k, v in pairs(invArgs) do | ||
invArgs_list[#invArgs_list + 1] = k | |||
end | |||
table.sort(invArgs_list) | |||
for i, v in ipairs(invArgs_list) do -- Add named args based on sorted parameter list | |||
ret[#ret + 1] = seps.pipe | ret[#ret + 1] = seps.pipe | ||
ret[#ret + 1] = | ret[#ret + 1] = v | ||
ret[#ret + 1] = seps.equals | ret[#ret + 1] = seps.equals | ||
ret[#ret + 1] = v | ret[#ret + 1] = invArgs[v] | ||
end | end | ||
ret[#ret + 1] = seps.closeb | ret[#ret + 1] = seps.closeb |