class Person { // Some data: String firstName; String lastName; int birthYear; // This is called a constructor: public Person (String firstName, String lastName, int birthYear) { this.firstName = firstName; this.lastName = lastName; this.birthYear = birthYear; } // A comparison method to allow two Person instances to be compared. public boolean lessThan (Person p) { // Compare the birthyear inside this instance (where we are executing) // with the birthyear of the parameter instance. if (birthYear < p.birthYear) { return true; } else { return false; } } } // end-of-Person public class ObjectSortExample { public static void main (String[] argv) { // Make space for 10 person pointers. Person[] someKennedys = new Person [10]; // Each array location is itself an object pointer. We // need to assign actual object instances using the new operator. someKennedys[0] = new Person ("Patrick", "Kennedy", 1858); someKennedys[1] = new Person ("Joseph", "Kennedy", 1888); someKennedys[2] = new Person ("Rose", "Fitzgerald", 1890); someKennedys[3] = new Person ("Joseph", "Kennedy", 1915); someKennedys[4] = new Person ("John", "Kennedy", 1917); someKennedys[5] = new Person ("Jacqueline", "Bouvier", 1929); someKennedys[6] = new Person ("Robert", "Kennedy", 1925); someKennedys[7] = new Person ("Edward", "Kennedy", 1932); someKennedys[8] = new Person ("Caroline", "Kennedy", 1957); someKennedys[9] = new Person ("Maria", "Shriver", 1955); System.out.println ("Unsorted: "); print (someKennedys); sort (someKennedys); System.out.println ("\nSorted: "); print (someKennedys); } static void print (Person[] people) { for (int i=0; i