private void sortPlayersScores(Player[] players, int[] playerScores) {
        int minScore, minScoreIndex, tempScore;
        Player tempPlayer;

        for (int i = 0; i < players.length - 1 && i < playerScores.length - 1; i++) {
            minScore = playerScores[i];
            minScoreIndex = i;

            for (int j = i + 1; j < players.length && j < playerScores.length; j++) {
                if (playerScores[j] < minScore) {
                    minScore = playerScores[j];
                    minScoreIndex = j;
                }
            }

            tempScore = playerScores[i];
            playerScores[i] = playerScores[minScoreIndex];
            playerScores[minScoreIndex] = tempScore;

            tempPlayer = players[i];
            players[i] = players[minScoreIndex];
            players[minScoreIndex] = tempPlayer;
        }
    }