Sorting Lists in Java with Comparators
August 31, 2014
I always forget how to write a comparator in Java, so here's an explanation for me to refer to.
You can sort a collection in Java using Collections.sort()
, passing in the collection and a Comparator:
List<Person> lPeopleList = new ArrayList<Person>(); lPeopleList.add …