How get key-value data from dictionary in organized order?

I have dictionary:

local Dictionary = {
	OakPlank = 1,
	MarshPlank = 2,
	GoldPlank = 3,
}

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

Alternatively you could use arrays:

local array = {
	{
		"OakPlank",
		1
	};
	{
		"MarshPlank",
		2
	};
	{
		"GoldPlank",
		3
	}
}
local dict = {["a"] = 1, ["b"] = 2, ["c"] = 3}
for i, v in pairs(dict) do
	print(i, v)
end

image

The order in which a dictionary of items/elements is traversed is arbitrary.