chimmmihc
|
  |
| Joined: 24 Jul 2014 |
| Total Posts: 2420 |
|
|
| 19 Oct 2015 05:46 AM |
| Anyone know of a super quick sorting algorithm? I'm sorting a table from least to greatest 1, to 10. |
|
|
| Report Abuse |
|
|
|
| 19 Oct 2015 05:57 AM |
| Could you explain a bit more? |
|
|
| Report Abuse |
|
|
chimmmihc
|
  |
| Joined: 24 Jul 2014 |
| Total Posts: 2420 |
|
|
| 19 Oct 2015 06:02 AM |
| How can I sort a table of numbers from 1, to 10. For example {1,9,6,7,3} to {1,3,6,7,9} |
|
|
| Report Abuse |
|
|
|
| 19 Oct 2015 06:06 AM |
table.sort()?
x = {1,9,6,7,3} table.sort(x) for i,v in pairs(x) do print(v) end |
|
|
| Report Abuse |
|
|
chimmmihc
|
  |
| Joined: 24 Jul 2014 |
| Total Posts: 2420 |
|
|
| 19 Oct 2015 06:15 AM |
| Would this work if I had something like t = {{value, 5}, {value, 7}, {value, 1}} |
|
|
| Report Abuse |
|
|
FlyNormal
|
  |
| Joined: 30 Sep 2015 |
| Total Posts: 344 |
|
|
| 19 Oct 2015 06:39 AM |
In that case, you will need to use the 2nd argument of table.sort.
table.sort(t, function(a, b) return a[2] < b[2] end) |
|
|
| Report Abuse |
|
|