Help navigating a dictonary

I have a diconary like the one below. I have a variable saved with the current index, ie: “Z-6”, how would i be able to get the next one, “DC-15X”, or go back one to the “DC-15A”, all the way the the end of the table.

Example: If the index variable is set at E-5, how can i navigate foward to “DC-15S”, or backwards to “L5”

Table:

local prices = {
	["Z-6"] = {
		["BM"] = 5000,
		["TGRA"] = 4800,
		["Pass"] = 111807495,
	},
	["DC-15X"] = {
		["BM"] = 5000,
		["TGRA"] = 4800,
		["Pass"] = 111807810,
	},
	["L3"] = {
		["BM"] = 500,
		["TGRA"] = nil,
		["Pass"] = 112055269,
	},
	["L5"] = {
		["BM"] = 1500,
		["TGRA"] = nil,
		["Pass"] = 112057014,
	},
	["E-5"] = {
		["BM"] = 1750,
		["TGRA"] = nil,
		["Pass"] = 112059827,
	},
	["DC-15S"] = {
		["BM"] = nil,
		["TGRA"] = 1750,
		["Pass"] = nil,
	},
	["DC-15A"] = {
		["BM"] = nil,
		["TGRA"] = 2500,
		["Pass"] = nil,
	},
}

Currently, dictionaries cannot be used iteratively if they have non-numeric keys. You can only go through each one in a random order. If you want to impose an order you might need a secondary table that lists the order in which to loop through the dictionary. I.E.

{ "E-5", "DC-15S", "DC-15A"}
-- this can be used to determine what is next

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.