Currently I'm trying to make a table for holding values. But when I use table.sort it just makes the highest go to the end(which I understand that's the intention with it).. but is there a way to make it sort from highest to lowest?
Yes, and believe it or not its using the same function table.sort
If you dont define a comparator in the sort function it will always default to less than
, which sorts from lowest to highest, to add a comparator just add a function in the second argument that returns if the value is higher
local table1 = {10,34,1,23} table.sort(table1,function(a,b) return a>b end) for i,v in pairs(table1) do print(v) end