I can not get it work:
tbl = {
[1] = { ['etc2'] = 14477 },
[2] = { ['etc1'] = 1337 },
[3] = { ['etc3'] = 1336 },
[4] = { ['etc4'] = 1335 }
}
for i = 1, #tbl do
table.sort(tbl, function(a, b) return a[i] > b[i] end)
print(tbl[i] .. '==' .. #tbl)
end
Getting this error: attempt to compare two nil values
This is a follow-on to table value sorting in lua
a[i]
is nil becausea
is a table with string indexes.