DevTurtIe
(DevTurtle)
#1
So for example this is what my table looks like:
local tableExample = {
{3, "APlayerName"},
{7, "APlayerName"},
{2, "APlayerName"},
{9, "APlayerName"},
}
and I want to make it go from largest value to smallest like this:
local tableExample = {
{9, "APlayerName"},
{7, "APlayerName"},
{3, "APlayerName"},
{2, "APlayerName"},
}
How would I be able to do this?
Also the Playernames don’t need to be sorted or anything only the value’s.
I guess this would need to be done with table.sort() but I can’t find how I would do this with a table inside of a table.
You can find a solution here
1 Like
Daw588
(Daw588)
#3
Just make the callback function compare the first item in each stored nested table.
table.sort(tableExample, function(a, b)
return a[1] > b[1]
end)
2 Likes
DevTurtIe
(DevTurtle)
#4
Thank you Both I was struggling with finding this but I understand now thank you for your help.