import java.util.Arrays; class Sorter2 { public static void main(String[] args) { // some data, clearly out of order Person[] arr = new Person[3]; arr[0] = new Person("Zach"); arr[1] = new Person("Lola"); arr[2] = new Person("Gerardo"); System.out.println(Arrays.toString(arr)); /* BubbleSort1.sort(arr); * Clearly, our old sort routine in BubbleSort1 is not going * to work, because it expects arr to be an int[]. * But arr is actually a Person[]! * * Instead, we'll solve the problem by making a new, generic * sort method in BubbleSort2. We also have to give it a * "compare method" because the > operator we used before * only makes sense for numbers. * * Recall from the definition of "sort algorithm" that it is * a procedure that takes: * 1. an unordered collection of data, arr. * 2. a comparison relation, c. */ PersonComparator c = new PersonComparator(); // we'll figure this out in the next class BubbleSort2.sort(arr, c); System.out.println(Arrays.toString(arr)); } }