Which interface must a class implement to be sortable using `Collections.sort()`?

Java Associate Medium

Java Associate — Medium

Which interface must a class implement to be sortable using `Collections.sort()`?

Key points

  • Comparable interface provides a way to define the natural ordering of objects.
  • Comparator interface is used for custom sorting logic, not for the default sorting behavior.
  • Sortable and Ordered are not standard interfaces in Java for sorting objects.

Ready to go further?

Related questions