Originally Posted by Phanx
As Dridzt said, you can't do that. That's the whole point of the code I posted. You bypass this "problem" by having one table that stores key/value pairs, and a second table that stores a sorted list of the keys from the first table. It's neither possible nor necessary to sort the keys in a table in Lua. The only sorting that's possible is on the values of an indexed table.
If you think that what I posted will not work for what you're trying to do, please explain more clearly what you're trying to do.
|
I understand that i just wanted to dodge to use the indexed method.
My table looks like this, and i want to reach each table easily, and since the table is gonna be really big i rather not keep more helper tables for it:
Lua Code:
local catz = {
-- Sorted table
[...],
["Unit: Player"] = {
-- Sort this like how you add the values
[...],
["PlayerFrame"] = {
-- Well this is sorted
[1] = "TopLeft",
[2] = "UIParent",
[3] = "TopLeft",
[4] = 19,
[5] = -4,
},
["PlayerPVPIcon"] = {
[1] = "TopLeft",
[2] = "PlayerFrame",
[3] = "TopLeft",
[4] = 18,
[5] = -20,
},
[...],
},
["Unit: Target"] = {
[...],
["TargetFrame"] = {
[1] = "TopLeft",
[2] = "UIParent",
[3] = "TopLeft",
[4] = 250,
[5] = -4,
},
[...],
},
[...],
}
The issue with the indexed method:
Lua Code:
local cats = {
["Unit: Player"] = {
[1] = {name = L["Player"], frame = "PlayerFrame", pos = {[1] = "TopLeft", [2] = "UIParent", [3] = "TopLeft", [4] = 19, [5] = -4,}},
},
}
How the hell am I gonna reach easily the "pos" table, if i only know the frame's name?