I have the following simple class, containing a String and an Int.
private static class SuggestionAndScore
{
private String suggestion;
private int score;
}
I will have a List of these objects which may contain up on 500,000 items.
What is the best way to sort this based on the value of score? Should I have the class implement Comparator and use Collections.sort on it or it there a better way?
Performance is critical so hence my question as I want to make sure I get the best solution.
If all your objects are unique then use
TreeSet. Gives the best performance since the objects are already stored in sorted order. (You need not even call Collections.sort())