List of utility methods to do Array Sort
void | sortInPlace(final double[] v, final int i, final int j) sort In Place if (v[i] > v[j]) { final double tmp = v[i]; v[i] = v[j]; v[j] = tmp; |
void | sortInPlace(int[] array) Sort array. populateCountsFromArray(array);
populateArrayFromCounts(array);
return;
|
byte[] | sortInterval(byte[] x, int start, int end) sort Interval assert start <= end; assert end <= x.length; final byte[] result = x.clone(); final int[] counter = new int[256]; for (int i = start; i < end; i++) { final int b = unsigned(x[i]); counter[b]++; int index = start; for (int i = 0; i < 256; i++) { for (int j = 0; j < counter[i]; j++) result[index++] = (byte) i; return result; |
void | sortKeyValuePairs(long[] keys, double[] values, int startInd, int endInd) Sorts a portion of the given key/value pairs by key. if (endInd - startInd <= 1) { return; int pivotInd = (int) (Math.random() * (endInd - startInd)) + startInd; swap(keys, values, startInd, pivotInd); pivotInd = startInd; for (int i = startInd + 1; i < endInd; i++) { if (keys[i] < keys[pivotInd]) { ... |
int | sortLeftRightAndCenter(double[] array, int[] index, int l, int r) Sorts left, right, and center elements only, returns resulting center as pivot. int c = (l + r) / 2; conditionalSwap(array, index, l, c); conditionalSwap(array, index, l, r); conditionalSwap(array, index, c, r); return c; |
void | sortMatrixRows(A[] matrix, Comparator super A> comparator) Sorts the matrix rows using the given comparator. Arrays.sort(matrix, comparator); |
double[] | sortMinMaxToMax(double[] min, double[] max) sort Min Max To Max double[] newMax = new double[3]; newMax[0] = Math.max(min[0], max[0]); newMax[1] = Math.max(min[1], max[1]); newMax[2] = Math.max(min[2], max[2]); return newMax; |
double[] | sortMinToMax(double[] v) Returns a sorted array from the minimum to the maximum value. double[] ans = copy(v); quickSortMinToMax(ans, 0, ans.length - 1); return (ans); |
void | sortNames(String[] names) sort Names System.out.print("Names: "); System.out.println(Arrays.toString(names)); String[] sortedNames = Arrays.copyOf(names, names.length); System.out.print("Sorted names:"); Arrays.sort(sortedNames); System.out.println(Arrays.toString(sortedNames)); System.out.println("The initial names array was sorted:" + Arrays.equals(sortedNames, names)); System.out.println("The new index of \"Brad Pitt\":" + Arrays.binarySearch(sortedNames, "Brad Pitt")); ... |
String[] | sortNames(String[] names) sort Names Arrays.sort(names);
return names;
|