View Single Post
05/30/14, 01:41 PM   #5
SinusPi
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 18
There's no way to do that, simply. Your table isn't even sorted by the keys, not to mention the value of the param1 attribute.

But, you can do something else.

Code:
tArray={}
tArray["name1"] = { param1 = 10, params2 = 20, param3 = 50}
tArray["name2"] = { param1 = 5, params2 = 45, param3 = 132}
tArray["name3"] = { param1 = 8, params2 = 55, param3 = 10}

bag = {}
for k,v in pairs(tArray) do
  table.insert(bag,{key=k,data=v})
end

table.sort(bag,function(a,b) return a.data.param1<b.data.param1 end)

for i,t in ipairs(bag) do
  print(t.key)
end
  Reply With Quote