|
| 14 Sep 2015 09:16 PM |
How would one sort a table of strings alphabetically?
choo choo |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2015 09:17 PM |
The table.sort function should do exactly what you want.
table.sort(YourTable) |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2015 09:18 PM |
^
You didn't even use it right. |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2015 09:21 PM |
I didn't even though there was such a thing! TO THE WIKI! TIME FOR EXTENSIVE RESEARCH!
choo choo |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2015 09:21 PM |
@MK could you explain to me how a "comp" (the second arg) works? like function(a,b) if a > b then return true else return false end end
Like that?? |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2015 09:22 PM |
| Yes I did. The second argument is optional, and the table of strings will be sorted lexically. |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2015 09:25 PM |
What if it was say, numbers? Can you give me an example of how to sort the numbers from largest to smallest and smallest to largest?
choo choo |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2015 09:31 PM |
To sort it from smallest to largest:
table.sort(YourTable, function(a, b) return a < b end)
And largest to smallest:
table.sort(YourTable, function(a, b) return a > b end) |
|
|
| Report Abuse |
|
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
|
| 14 Sep 2015 09:38 PM |
string:sub(1,1):lower():byte()
returns ascii equivalent I believe the less it is, the closer to a. |
|
|
| Report Abuse |
|
|