Sorting player scoreboard based on their score
I'm trying to sort my players on a scoreboard based on their score so the one with the highest score is at the top but I dont have any idea how to do it, the score gets assigned using the PhotonNetwork.Player.GetScore();
Gets the players name / score:
[SerializeField] TMP_Text text;
Player player;
public void SetUp(Player _player)
{
player = _player;
text.text = _player.NickName;
Debug.Log(_player.NickName);
}
public void SetUpsc(Player _player)
{
player = _player;
text.text = _player.GetScore().ToString();
}
Displays the player:
Player[] players = PhotonNetwork.PlayerList;
for (int i = 0; i < players.Count(); i++)
{
Instantiate(PlayerListItemPrefab, ScoreListContent).GetComponent<PlayerListItem>().SetUp(players[i]); //player name
Instantiate(PlayerSListItemPrefab, ScoreSListContent).GetComponent<PlayerListItem>().SetUpsc(players[i]); //Player Score Value
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613011658im_/https://answers.unity.com/themes/thub/images/avi.jpg)