X714: Write A Comparator 1

For this question, we will be sorting Person objects. Here is the Person class so you’ll know what you have available:

public class Person{



    private int age;
    private String name;
    private String grade;

    public Person(int a, String n, String gr) {
        age = a;
        name = n;
        grade = gr;
    }


    public int getAge() {
        return age;
    }


    public String getGrade() {
        return grade;
    }

}

For this question implement a compare method that will sort people by age from youngest (lowest age) to oldest (highest).

Your Answer:

Feedback

Your feedback will appear here when you check your answer.