diff options
Diffstat (limited to 'server/src/utility.lua')
-rw-r--r-- | server/src/utility.lua | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/server/src/utility.lua b/server/src/utility.lua index 3f0df110..a4072510 100644 --- a/server/src/utility.lua +++ b/server/src/utility.lua @@ -10,6 +10,8 @@ local next = next local rawset = rawset local move = table.move local setmetatable = setmetatable +local tableSort = table.sort +local mathType = math.type local TAB = setmetatable({}, { __index = function (self, n) self[n] = string_rep('\t', n) @@ -41,16 +43,19 @@ function table.dump(tbl) else KEY[key] = key end - elseif math_type(key) == 'integer' then - KEY[key] = ('[%d]'):format(key) + elseif mathType(key) == 'integer' then + KEY[key] = ('[%03d]'):format(key) else KEY[key] = ('<%s>'):format(key) end keys[#keys+1] = key end - table_sort(keys, function (a, b) - return KEY[a] < KEY[b] - end) + local mt = getmetatable(tbl) + if not mt or not mt.__pairs then + tableSort(keys, function (a, b) + return KEY[a] < KEY[b] + end) + end for _, key in ipairs(keys) do local value = tbl[key] local tp = type(value) |