I have a Score System that I want to create, in which there is a list of players ranging their score from highest to lowest.
My PlayerObject.class Class:
public class PlayerObject {
private String playerName;
private int playerScore;
public int getScore() {
return this.playerScore;
}
public String getName() {
return this.playerName;
}
public void setNameAndScore(String givenName, int givenScore) {
this.playerName = givenName;
this.playerScore = givenScore;
}
}
My Array:
ArrayList<PlayerObject> allPlayers = new ArrayList<PlayerObject>();
Any idea how I can sort each player in the array list based on their playerScore attribute?