Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesnt this Table get printed out in the "correct" order?

I have got a Table that looks something like that:

local ChooseFrom = { S = 23; H = 50; A = 90; V = 158; Ai = 256; G = 358; K = 469; L = 611; O = 756; F = 1000;

} but instead of rinting it this way its printed like that:

H50 L611 G358 V158 F1000 O756 A90 K469 S23 Ai256

Why does this occure and how can i make it get printed out in the order its meant to get printed?

4 answers

Dictionaries have no order, if the order is important you should use an array instead.

Dictionaries have no order as they are stored as Hash Maps and as such there is no order in their algorithm. This is expected behaviour.

As previously said dictionaries have no order. Luckily arrays do! You can get the order by using the ipairs() to cycle through based on index number!

This should work:

— Put the table up here

for i, v in pairs(ChooseFrom) do
     print(v)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.