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
public class DogAgeComparator implements Comparator { public int compare(Dog o1, Dog o2) { return Integer.compare(o1.getAge(), o2.getId()); } }