C#C
C#10mo ago
Qualy

player ranking

So,...
I am meant to rank the player list based on their wins. I now made something that will sort the players after they win. Problem is it only gets executed once.
C#
void SortPlayers(string winnerName)
{
    int winnerIndex = playerNames.IndexOf(winnerName);
    int aboveWinnerIndex = winnerIndex - 1;
    if (aboveWinnerIndex >= 0)
    {
        string aboveWinnerName = playerNames[aboveWinnerIndex];
        if (playerWins[winnerName] > playerWins[aboveWinnerName])
        {
            playerNames[aboveWinnerIndex] = winnerName;
            playerNames[winnerIndex] = aboveWinnerName;
        }
    }
    UpdatePlayerList();
}

playerNames is a list
playerWins is a dictionary
image.png
Was this page helpful?