Collections - Sorting ArrayList of user-defined objects
Table of Contents
How do you sort an ArrayList (or any list) of user-defined objects ?
Create an implementation of the java.lang.Comparable interface that knows how to order your objects and pass it to java.util.Collections.sort(List, Comparator). If we use Collections.sort(arraylist), the elements in the arraylist will be sorted by natural order.