If you’re sorting it then it’ll sort in ASC order, meaning 10 would be the first value. So the number before the sort if 15 as that was the first number in the table
local t = {15,7,66,93,10}
local total = 0
table.sort(t,function(a,b)
print(t)
print("a = previous number = "..a)
print("b = current number = "..b)
return a > b
end)
prints previous number as middle number
and current number as 7
a is not previous number, it will be next number in here right
I believe that the a and b are just 2 different numbers that are selected in the table (in such a way where every number can be sorted). If you return true, that number will be “sorted” (if it’s true, a will be before b in the table).
For example, in this code block:
local t = {1, 2, 3, 4, 5}
table.sort(t, function(a, b)
return a < b -- If "a" is smaller than "b", "a" will appear before "b"
end)
print("\n")
for i, v in pairs(t) do
print(i, v)
--[[
Notice that the table is now sorted from least to greatest
Take note that during our table.sort function on line 3 - 5,
we put "a" before "b" if "a" is smaller than "b", which
caused the table to sort like this
--]]
end