unity sort a list 1

unity sort a list

playerList.Sort((p1,p2)=>p1.score.CompareTo(p2.score));

Here is what the above code is Doing:
1. We’re creating a new list called playerList.
2. We’re adding the player objects to the list.
3. We’re sorting the list by the score property of the player objects.
4. We’re printing the list.

Similar Posts