Speaking of the more commonly used sort functions in the table Library of Lua--table.sort (), the first parameter represents the table to be sorted, the second parameter is optional, and if there is no second argument, the function will sort the table element from small to large. I would mainly say the second parameter.
The second argument is the function type, which receives two table elements and should return TRUE if you want the first parameter to be in the sort result before the second argument. Then the most intuitive understanding is to look at the code, as follows is a way of writing
Local tab = {3,5,4,1,2}
local function comp (b)
return a > B
end
Table.sort (Tab,comp)
for I =1, #tab do
print (tab[i])
end
Another way of writing is anonymous function writing, relatively simple, I am not on the code here, the intention of the reader can do their own.