How do I get all players in order most to least stats

Hello, I’m currently trying to get a list of players, worst to least amount of candy collected in a round. I have spent around 3 hours straight trying to either figure out how to use table.sort() or looking for some form of a tutorial

  1. What do you want to achieve? I am trying to get a list of who has collected the most candy to the least candy at the end of each round

  2. What is the issue? I really cant figure it out

  3. What solutions have you tried so far? I’ve looked everywhere

1 Like

Have you attempted using Table.Sort? I saw your last post It would be the best solution for your problem.

1 Like

I’ve really tried, either I’m not thinking straight because its 4:11 am or I just need a good explanation on how to use it

I actually didn’t quite get it myself then I googled and seen some examples on old devforum posts about how to properly use It
Code I tested with


local TableTest = {
	{"P1",10},	{"P2",20},
	{"P3",100},{"P4",590},

}
print(TableTest)
table.sort(TableTest,function(a,b)
	return a[2] > b[2]
end)
print(TableTest)

my output log
image

So would I replace the numbers in the table with player.Value

Ill do some testing around with it

Thanks a lot, did some testing and I think i got the hang of it for the most part

1 Like