import java.util.Comparator; import java.util.Arrays; public class SortIntegers { public static void main(String[] args) { // Establish an ArraySorter whose resident comparator defines // the usual ordering on integers. ArraySorter sorter = new SelectionSorter(new IntComparator()); // Make a sample array and display it. Integer[] ary = { 15, 23, 9, -4, 12, 5, 9, -2, 8, 5 }; System.out.println("Array to be sorted:"); System.out.println(Arrays.toString(ary)); // Sort the array and print its updated contents sorter.sort(ary); System.out.println("\nAfter sorting, array is now:"); System.out.println(Arrays.toString(ary)); } private static class IntComparator implements Comparator { public int compare(Integer a, Integer b) { return a - b; } } }