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
Follow this Question
Related Questions
Sorting player scoreboard based on their score 0 Answers
Referencing a function in a C# script 1 Answer
Match making in Photon 0 Answers
How to sort and detect pattern? 0 Answers