How-to articles, tricks, and solutions about COMPARATOR

How to use Comparator in Java to sort

To use a Comparator in Java to sort a list of objects, you can use the Collections.sort method and pass it a List and a Comparator.

Sort ArrayList of custom Objects by property

To sort an ArrayList of custom objects by a property, you can use the Collections.sort method and pass it a custom Comparator.