package com.lovecoding.day12.interface04_2;

import java.util.Comparator;

public class PersonCompator implements Comparator {
    @Override
    public int compare(Object o1, Object o2) {

        Person p1 = (Person) o1;
        Person p2 = (Person) o2;

        //姓名  年龄
        return p1.getName().compareTo(p2.getName()) == 0 ? p1.getAge() - p2.getAge() : p1.getName().compareTo(p2.getName());
    }
}
