Module:Common

-- Common utility functions local common = {} -- Iterator for iterating over a table in a given order function common.sortedPairs(t, desc) -- collect the keys local keys = {} for k in pairs(t) do keys[#keys+1] = k end if (desc) then table.sort(keys, function(key1, key2)           return key1 > key2        end) else table.sort(keys) end -- return the iterator function local i = 0 return function i = i + 1 if keys[i] then return keys[i], t[keys[i]] end end end return common