If i try to output this table, they are looped through in the false order:
local letters = {DIN1="hi", AIN1= "my", AIN2 ="name", DIN2="is"}
for name, value in pairs(letters) do
print(name,value)
end
Expected Output:
DIN1 hi
AIN1 my
AIN2 name
DIN2 is
Output:
AIN1 my
DIN2 is
DIN1 hi
AIN2 name
How can i code it so that the for loop runs through the tables actual order? (The order how it was defined)
Edit: I don't need the alphabetic order, but the same order as in the definition of the table.
Edit: I need to have the key AND the value printed. In the answer "Lua in pairs with same order as it's written" there will be only indexnumber and value printed