Tables with string keys are unordered but you can use pairs to return the key/values in whatever order they're found in.
ipairs is for a numerically orderd tables, the same as
Lua Code:
for i=1, #table do
-- return i, table[i] -- figurative return
end
Lua Code:
for key, value in pairs(stringKeyedTable) do
print(key, value)
end
for key, value in ipairs(numericKeyedTable) do
print(key, value)
end
In your table, ItemTable, contains a list of sub-tables in numeric order. The sort, resorted them based on the ItemName key each sub-table has.