/** * Sorts the elements in the list according to their Comparator. */ public void sort() { if (size > 1) { // sort the spatial list using the comparator if(listSort.getLength() != size){ listSort.allocateStack(size); } listSort.sort(geometries,comparator); } }
public static void main(String[] argv) { Integer[] arr = new Integer[]{5, 6, 2, 9, 10, 11, 12, 8, 3, 12, 3, 7, 12, 32, 458, 12, 5, 3, 78, 45, 12, 32, 58, 45, 65, 45, 98, 45, 65, 2, 3, 47, 21, 35}; ListSort ls = new ListSort(); ls.allocateStack(34); ls.sort(arr, new Comparator<Integer>() { public int compare(Integer o1, Integer o2) { int x = o1 - o2; return (x == 0) ? 0 : (x > 0) ? 1 : -1; } }); for (Integer integer : arr) { System.err.print(integer + ","); } System.err.println(); }
public static void main(String[] argv) { Integer[] arr = new Integer[]{5, 6, 2, 9, 10, 11, 12, 8, 3, 12, 3, 7, 12, 32, 458, 12, 5, 3, 78, 45, 12, 32, 58, 45, 65, 45, 98, 45, 65, 2, 3, 47, 21, 35}; ListSort ls = new ListSort(); ls.allocateStack(34); ls.sort(arr, new Comparator<Integer>() { public int compare(Integer o1, Integer o2) { int x = o1 - o2; return (x == 0) ? 0 : (x > 0) ? 1 : -1; } }); for (Integer integer : arr) { System.err.print(integer + ","); } System.err.println(); }
/** * Sorts the elements in the list according to their Comparator. */ public void sort() { if (size > 1) { // sort the spatial list using the comparator if(listSort.getLength() != size){ listSort.allocateStack(size); } listSort.sort(geometries,comparator); } }