View Single Post
05/30/14, 12:44 PM   #1
McGuffin
Join Date: Apr 2014
Posts: 5
Sorting a table in lua

Hi, i am trying to figure how to sort a table with multiple entries

Here is my problem.
I have something like that
Code:
tArray["name1"] = { param1 = 10, params2 = 20, param3 = 50}
tArray["name2"] = { param1 = 5, params2 = 45, param3 = 132}
tArray["name3"] = { param1 = 8, params2 = 55, param3 = 10}
now i want to sort tArray, by using the param1 order.
so i tried somthing like that
Code:
function sortParam1(a,b)
   return a[1]<b[1]
end

table.sort(tarray, sortParam1)
but that doesnt work...
is everyone know a way to do this?
  Reply With Quote