Module:Table/sortedPairs
Appearance
Documentation for this module may be created at Module:Table/sortedPairs/doc
local table_keys_to_list_module = "Module:table/keysToList"
local function keys_to_list(...)
keys_to_list = require(table_keys_to_list_module)
return keys_to_list(...)
end
--[==[
Iterates through a table, with the keys sorted using the keysToList function.
If there are only numerical keys, `export.sparseIpairs` is probably faster.]==]
return function(t, key_sort)
local list, i = keys_to_list(t, key_sort), 0
return function()
i = i + 1
local k = list[i]
if k ~= nil then
return k, t[k]
end
end
end