Im trying to learn comparator in java and I have found this great example online, my question is how would this code be changed so that the pet names are ordered by age and
From Java 8 you can use :
Comparator.comparingInt(Dog::getDogAge).reversed();