Sorting { public static void SortByType(int attribute, Comparable[] a){ sortBy = attribute; if (attribute == 0){ aux = new Comparable[a.length]; mergeSort(a, aux, 0, a.length); } if (attribute == 1){ aux = new Comparable[a.length]; mergeSort(a, aux, 0, a.length); } if (attribute == 2){ aux = new Comparable[a.length]; mergeSort(a, aux, 0, a.length); } if (attribute == 3){ shuffle(a); quickSort3way(a, 0, a.length - 1); } if (attribute == 4){ shuffle(a); quickSort3way(a, 0, a.length - 1); } if (attribute == 5){ shuffle(a); quickSort3way(a, 0, a.length - 1); } if (attribute == 6){ shuffle(a); quickSort3way(a, 0, a.length - 1); } if (attribute == 7){ shuffle(a); quickSort3way(a, 0, a.length - 1); } }  static void SortByType(int attribute, Comparable[] a); static void exch(Object[] arr,Object elem, int pos);  }
@Test public void sortByNameTest() { Sorting.SortByType(6, a); for(int i = 0; i < a.length-1;i++){ assert(a[i].getName().compareTo(a[i+1].getName()) < 0); } }
@Test public void sortByStateTest() { Sorting.SortByType(7, a); for(int i = 0; i < a.length-1;i++){ assert(a[i].getState().compareTo(a[i+1].getState()) < 0); } }
@Test public void sortByScoreTest() { Sorting.SortByType(5, a); for(int i = 0; i < a.length-1;i++){ assert(a[i].getScore() < a[i+1].getScore()); } }
@Test public void sortByZipTest(){ Sorting.SortByType(2,a); for(int i = 0; i < a.length - 1; i++){ assert(a[i].getZip().compareTo(a[i + 1].getZip()) < 0); } }