Hello, I made this table and I want to print it in order, how would I do this?
local tableThing = { hello = 'Hello', hi = 'Hi', hai = 'Hai'}
This is just an example. I attempted this but it printed them randomly, not in order.
for i, child in pairs(tableThing) do print(child) end
You don't. Dictionaries are unordered sets, unlike normal arrays, which have indexes. Without another function to order your dictionary, it won't do it automatically. I would just not use a dictionary in your case.
local t = {'hi', 'hello'} print ( table.concat(t, ', ') )
or
local t = { {name = 'hi', othervalue = 1}, {name = 'hello', othervalue = 'string'} } table.insert(t, {name = 'harry potter', othervalue = true}) for i,v in pairs(t) do print(v.name) end