List of utility methods to do Array Sort
void | sort(int[] intValues) sort int idxs[] = intValues; int length = idxs.length; for (int gap = length / 2; gap > 0; gap /= 2) { for (int i = gap; i < length; i++) { for (int j = i - gap; j >= 0; j -= gap) { if (idxs[j] > idxs[j + gap]) { int swap = idxs[j]; idxs[j] = idxs[j + gap]; ... |
void | sort(int[] keys, int[] values) Sorts the keys in an increasing order. hybridsort(keys, values, 0, keys.length - 1); |
void | sort(int[] values) Sorts an interger array. int length = values.length; if (length > 1) { for (int i = 0; i < (length - 1); i++) { for (int j = i + 1; j < length; j++) { if (values[j] < values[i]) { int temp = values[i]; values[i] = values[j]; values[j] = temp; ... |
Number[] | sort(Number[] array) Returns a sorted copy of the array (ascending). return sort(array, true);
|
O[] | sort(O[] array) Sorts the given array by its natural order of objects and then returns it, assuming the natural order of the elements follows the Comparable contract. Arrays.sort(array);
return array;
|
void | sort(Object[] a) sort Arrays.sort(a); |
void | sort(Object[] arr, int start, int end) sort if (end - start <= 2) { if (end - start == 2 && arr[start].toString().compareTo(arr[start + 1].toString()) > 0) { Object tmp = arr[start]; arr[start] = arr[start + 1]; arr[start + 1] = tmp; return; if (end - start == 3) { sort(arr, start, start + 2); sort(arr, start + 1, start + 3); sort(arr, start, start + 2); return; int middle = (start + end) / 2; sort(arr, start, middle); sort(arr, middle, end); Object[] tmp = new Object[end - start]; int i0 = start; int i1 = middle; for (int i = 0; i < tmp.length; i++) { if (i0 == middle) { tmp[i] = arr[i1++]; } else if (i1 == end || arr[i0].toString().compareTo(arr[i1].toString()) < 0) { tmp[i] = arr[i0++]; } else { tmp[i] = arr[i1++]; System.arraycopy(tmp, 0, arr, start, tmp.length); |
void | sort(Object[] array) Performs a quicksort of the given objects by their string representation in ascending order. qsort(array, 0, array.length - 1); |
void | sort(Object[] array, Comparator comparator) sort sort(array, array.length, comparator); |
void | sort(Object[] array, int start, int end) Sorts the specified range in the array in ascending order. int middle = (start + end) / 2; if (start + 1 < middle) sort(array, start, middle); if (middle + 1 < end) sort(array, middle, end); if (start + 1 >= end) return; if (((Comparable<Object>) array[middle - 1]).compareTo(array[middle]) <= 0) ... |