How to make a sorting function that sorts based on highest score and latest entry

:slight_smile: ello everyone!

I am working on a board game project (Similar to the actual IRL board game “Camel up”) and i got stuck on the leaderboard.

Summary of the idea

– each player, in their turn, can choose to roll the dice :

  • a random colored dice rolls (White,yellow,red,green,blue) and a random number between 1 to 3 is assigned to that specific dice.

  • a pawn specific to that color is moving on the board, based on his dice roll value.

  • if, let’s say, White rolled 3 and then Yellow rolls 3 then yellow it’s 1st in leaderboard and the leaderboard has to be updated before the next dice is rolled.

  • when all 5 dices are rolled the round is over.

Example of what it needs to be:

  • White rolls 3 (1st place);
    -Yellow rolls 2 (2nd place);
    -Red rolls 3 ( now he has to be 1st place, White 2nd place, yellow 3rd place);
    -Green rolls 1 ;
    -Blue rolls 3 (now he has to be 1st place…etc);

After the round the leaderboard should look like this:

1st - Blue (3 - last to roll the 3);
2nd - Red (3 - second to last to roll 3);
3rd - White (3 - first to roll 3);
4th - Yellow ( 2);
5ft - Green (1);

Also, the game consist of multiple rounds and each pawn knows his position on the board at each moment of the game.

the first pawn to cross from tile 16 to tile 17 wins and the game stops.

I can’t find a proper sorting so each round there is a “Round Leaderboard” but also a “Game Leaderboard” to show at the end of the game which pawn is the winner which pawn is the loser.

If anyone has any idea of how i can make something like what i am asking, please help.

Thanks for your time and have a nice day! :slight_smile: