inapt
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 11666 |
|
|
| 24 Oct 2014 10:00 PM |
I have a table of tables:
local tab = { {false, "lip"}, {true, "abc"}, {true, "def"}, }
How can I sort this alphabetically, by the second value inside of each element inside of tab? I want it to result to this:
local tab = { {true, "abc"}, {true, "def"}, {false, "lip"} } |
|
|
| Report Abuse |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Oct 2014 10:01 PM |
table.sort(tab, function(a, b) return b[2] > a[2]; end);
Not tested but should work |
|
|
| Report Abuse |
|
inapt
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 11666 |
|
| |