/** * Sorts the specified array into ascending numerical order. * @return the original index of elements after sorting in range [0, n). */ public static int[] sort(int[] arr) { int[] order = new int[arr.length]; for (int i = 0; i < order.length; i++) { order[i] = i; } sort(arr, order); return order; }
/** * Sorts the specified array into ascending order. * @return the original index of elements after sorting in range [0, n). */ public static <T extends Comparable<? super T>> int[] sort(T[] arr) { int[] order = new int[arr.length]; for (int i = 0; i < order.length; i++) { order[i] = i; } sort(arr, order); return order; }
/** * Sorts the specified array into ascending numerical order. * @return the original index of elements after sorting in range [0, n). */ public static int[] sort(double[] arr) { int[] order = new int[arr.length]; for (int i = 0; i < order.length; i++) { order[i] = i; } sort(arr, order); return order; }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static <T extends Comparable<? super T>> void sort(T[] arr, int[] brr) { sort(arr, brr, arr.length); }
/** * Sorts the specified array into ascending numerical order. * @return the original index of elements after sorting in range [0, n). */ public static int[] sort(float[] arr) { int[] order = new int[arr.length]; for (int i = 0; i < order.length; i++) { order[i] = i; } sort(arr, order); return order; }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(double[] arr, Object[] brr) { sort(arr, brr, arr.length); }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static <T extends Comparable<? super T>> void sort(T[] arr, Object[] brr) { sort(arr, brr, arr.length); }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(int[] arr, Object[] brr) { sort(arr, brr, arr.length); }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(float[] arr, Object[] brr) { sort(arr, brr, arr.length); }
/** * This is an effecient implementation Quick Sort algorithm without * recursive. Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(double[] arr, double[] brr) { sort(arr, brr, arr.length); }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(int[] arr, int[] brr) { sort(arr, brr, arr.length); }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(float[] arr, int[] brr) { sort(arr, brr, arr.length); }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(float[] arr, float[] brr) { sort(arr, brr, arr.length); }
/** * Besides sorting the array arr, the array brr will be also * rearranged as the same order of arr. */ public static void sort(double[] arr, int[] brr) { sort(arr, brr, arr.length); }
/** * Sorts each variable and returns the index of values in ascending order. * Note that the order of original array is NOT altered. * * @param x a set of variables to be sorted. Each row is an instance. Each * column is a variable. * @return the index of values in ascending order */ public static int[][] sort(double[][] x) { int n = x.length; int p = x[0].length; double[] a = new double[n]; int[][] index = new int[p][]; for (int j = 0; j < p; j++) { for (int i = 0; i < n; i++) { a[i] = x[i][j]; } index[j] = QuickSort.sort(a); } return index; }
@Nonnull public static int[][] sort(@Nonnull final Attribute[] attributes, @Nonnull final double[][] x) { final int n = x.length; final int p = x[0].length; final double[] a = new double[n]; final int[][] index = new int[p][]; for (int j = 0; j < p; j++) { if (attributes[j].type == AttributeType.NUMERIC) { for (int i = 0; i < n; i++) { a[i] = x[i][j]; } index[j] = QuickSort.sort(a); } } return index; }
/** * Sorts each variable and returns the index of values in ascending order. * Only numeric attributes will be sorted. Note that the order of original * array is NOT altered. * * @param x a set of variables to be sorted. Each row is an instance. Each * column is a variable. * @return the index of values in ascending order */ public static int[][] sort(Attribute[] attributes, double[][] x) { int n = x.length; int p = x[0].length; double[] a = new double[n]; int[][] index = new int[p][]; for (int j = 0; j < p; j++) { if (attributes[j].getType() == Attribute.Type.NUMERIC) { for (int i = 0; i < n; i++) { a[i] = x[i][j]; } index[j] = QuickSort.sort(a); } } return index; }
QuickSort.sort(o, itemset, t);
double[] prediction = probability.clone(); QuickSort.sort(prediction, label);