I have populated an ArrayList with Boat objects. The boat has a name, an ID and a score. I need to compare the scores, integers, with eachother and order them from lowest to highest.
I've tried a lot, and failed a lot and I'm stumped on what to do.
public class Boat {
private String name;
private int id;
private int score;
//Constructor
public Boat(String name, int id, int score) {
this.name = name;
this.id = id;
this.score = score;
}
I've found the Comparator class, but can't figure out how to use it properly.
Basically what I need to do is to sort the scores into a new ArrayList. Moving them from my private ArrayList<Boat> participants;
list to my private ArrayList<Boat> sortedScoreList;
list in descending order.
This is my first time posting on here, so please let me know if I need to add more information.