Here is the link for the API reference: https://docs.coronalabs.com/api/library/table/sort.html
I was looking at this function and had some questions about how to get it to work for my situation.
I have a table as follows
local spots = { [1] {X = 100, Y = 100, Distance = 350}, [2] {X = 75, Y = 150, Distance = 450}, [3] {X = 150, Y = 200, Distance = 100}, [4] {X = 100, Y = 120, Distance = 200}, }
The table.sort() function API doesn’t seem to go into painful detail about how to set up the function.
I would like for it to look at my table and compare the Distance values and sort them in ascending order, so the smallest distance is in spots[1].
I was hoping maybe someone could explain a little bit about the API page and explain to me what the “a, b” would reference in the example and how I could set up the function to get it to sort depending on the distance value.
Thanks guys