how do i alphabetically sort an array
1 Like
You should be able to use table.sort
Here’s an example (un-tested):
local arrayToSort = ['y', 'l', 'i']
table.sort(arrayToSort, function(a,b)
return a < b
end)
1 Like
This is what table.sort
does by default so table.sort(arrayToSort)
is the same.
You could do
table.sort(arrayToSort, function(a, b) return a:lower() < b:lower() end)
If you wanted to ignore case
2 Likes
Cool, haven’t used table.sort much so I was unaware. Also yeah, I was gonna add that but I didn’t know if he wanted it to sort by case aswell
1 Like