Modul:table/keysToList
Robâ
Dokumentasi untuk modul ini dapat dibuat di Modul:table/keysToList/doc
local relation_module = "Module:relation"
local pairs = pairs
local sort = table.sort
local compare
local function get_compare()
compare, get_compare = require(relation_module).compare, nil
return compare
end
--[==[
Returns a list of the keys in a table, sorted using either the default `table.sort` function or a custom `key_sort` function.
If there are only numerical keys, [[Module:table/numKeys]] is probably faster.]==]
return function(t, key_sort)
local list, i = {}, 0
for key in pairs(t) do
i = i + 1
list[i] = key
end
-- Use specified sort function, or otherwise `compare`.
sort(list, key_sort or compare or get_compare())
return list
end