I saw an example on here how to sort an ArrayList using the Comparator interface, so I tried it out. With Strings it worked perfectly, but with one variable that I want to sort being an Integer, it will not compile, saying "int cannot be dereferenced".
What can I do so that this will work and allow me to sort an ArrayList by the score variable?
Here's my code:
public class ScoreComparator implements Comparator<Review> {
@Override
public int compare(Review o1, Review o2)
{
return o1.getScore().compareTo(o2.getScore());
}
}