CustomComparator sort objects error <p>I keep getting the error </p> <pre><code>The method sort(List&lt;T&gt;, Comparator&lt;? super T&gt;) in the type Collections is not applicable for the arguments (List&lt;InterfaceMessage&gt;, Folder.CustomComparator) </code></pre> <p>on the code...</p> <pre><code>@Override public void sortByDate(boolean ascending) { Collections.sort(messageList, new CustomComparator()); } class CustomComparator implements Comparator&lt;Message&gt; { public int compare(Message message1, Message message2) { return message1.getDate().compareTo(message2.getDate()); } } </code></pre> <p>I'm trying to compare the dates within each object in a list to order them by their dates. I'm new to making a comparator but I have seen many examples which I've followed but mine doesn't seem to work? I know I haven't done anything with "ascending" yet, I just want to get the basic comparator working.</p> <p>Any help is appreciated, thank you :)</p>