iiAu
|
  |
| Joined: 27 Sep 2015 |
| Total Posts: 86 |
|
|
| 04 Feb 2017 10:34 PM |
You can't use table.sort on a table like this, a table of tables!
local table = {{5, "t"},{3, "x"},{2, "y"},{4, "n"},{1, "m"}}
You're supposed to sort the first index of every table from least to greatest, in this case the numbers
I don't know anything like metatables or anything to sort this. Give a little help?
|
|
|
| Report Abuse |
|
|
|
| 04 Feb 2017 10:35 PM |
| Insert the indexes into a table and sort it. |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2017 10:37 PM |
| table.sort(t,function(a,b) return #### < b[1] end) |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2017 10:37 PM |
Don't do that...
local table = {{5, "t"},{3, "x"},{2, "y"},{4, "n"},{1, "m"}}
table.sort(table, function(a, b) return a[1] < b[1] end)
|
|
|
| Report Abuse |
|
|
iiAu
|
  |
| Joined: 27 Sep 2015 |
| Total Posts: 86 |
|
|
| 04 Feb 2017 10:37 PM |
But then I would need to refer back to the table... If I were to create another table and then have it be sorted and have all that information being copied back on to those tables, that would be a lot of work. And a little unneat, maybe.
|
|
|
| Report Abuse |
|
|
| |
|
iiAu
|
  |
| Joined: 27 Sep 2015 |
| Total Posts: 86 |
|
|
| 04 Feb 2017 10:38 PM |
Oh, neato! I wasn't seeing the posts. Thank you
|
|
|
| Report Abuse |
|
|
|
| 04 Feb 2017 10:38 PM |
i win i replied with an answer first
|
|
|
| Report Abuse |
|
|