Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
esepek 103
4 years ago

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

Log in to vote
1
Answered by
iOwn_You 543 Moderation Voter
4 years ago

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

Ad
Log in to vote
0
Answered by
ACHRONlX 255 Moderation Voter
4 years ago

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.

Log in to vote
0
Answered by 4 years ago

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!

Log in to vote
0
Answered by 4 years ago

This should work:

— Put the table up here

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

Answer this question