How I can get data from this dictionary in correct order like this: OakPlank --> MarshPlank --> GoldPlank,
instead of random order when using in pairs()?
I don’t think in pairs() does it in random order. It does it in the order of the dictionary contents. So it would still be OakPlank. --> MarshPlank --> GoldPlank unless you configure how the dictionary is sorted.
You will need an index variable if you want to return a specific order. For example:
local Dictionary = {
OakPlank = {
v = 1,
index = 1
},
MarshPlank = {
v = 2,
index = 2
},
GoldPlank = {
v = 3,
index = 3
},
}
do
local t = {}
for k, v in pairs(Dictionary) do
t[v["index"]] = k
end;
print(t)
end