Prototype: fix table.sort failing to compare number keys with string keys

This commit is contained in:
Nero 2022-06-17 23:40:50 +00:00
parent f2af58a653
commit 8080b79b68

View File

@ -25,7 +25,7 @@ function Prototype:__tostring()
-- load and sort table keys -- load and sort table keys
local tkeys={} local tkeys={}
for k in pairs(self) do table.insert(tkeys, k) end for k in pairs(self) do table.insert(tkeys, k) end
table.sort(tkeys) table.sort(tkeys, function(a,b) return tostring(a)<tostring(b) end)
-- iterate over our table -- iterate over our table
for _,k in ipairs(tkeys) do for _,k in ipairs(tkeys) do
local v = Prototype.__tostring(self[k]) local v = Prototype.__tostring(self[k])