I'm working on a card game with AI, and one thing I need to do in the main card selection algorithm is to sort card according to their number. So I have a card object that has things such as Card.Suit, Card.Attribute, and more importantly Card.Number. I've looked at the table sort function and it only seems to give examples on sorting numbers, rather than by object elements. Is there a way to do this? I assumed it will be something along the lines of the given example:
cards = {
{x = 1, n = 65},
{x = 2, n = 577},
{x = 3, n = 1}}
sort = function(cardA, cardB)
return cardA.n < cardB.n
end
table.sort(cards, sort)
The a and b arguments in the sorting function are two element of the table you will sort, so if the table only contain numbers they'll be numbers, if it contains other tables they'll be those tables
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics