Class Sort
java.lang.Object
org.apache.datasketches.tdigest.Sort
Specialized sorting algorithm that can sort one array and permute another array the same way.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidreverse(double[] values, int n) Reverse the first n elements of the given array.static voidreverse(long[] values, int n) Reverse the first n elements of the given array.static voidstableSort(double[] keys, long[] values, int n) Sort two arrays so that the result is deterministic.
-
Constructor Details
-
Sort
public Sort()No argument constructor.
-
-
Method Details
-
stableSort
public static void stableSort(double[] keys, long[] values, int n) Sort two arrays so that the result is deterministic. The elements are ordered by key (ascending) and, if the keys are equal, by the paired value (ascending). The first array is sorted while the second array is permuted the same way.Because the pairs (key, value) are totally ordered, the output depends only on the multiset of pairs and not on the initial order of the elements nor on the choice of pivots.
- Parameters:
keys- array to be sortedvalues- array to be permuted the same way, also used to break ties between equal keysn- number of elements to sort from the beginning of the arrays
-
reverse
public static void reverse(double[] values, int n) Reverse the first n elements of the given array.- Parameters:
values- array to be reversedn- number of elements to reverse
-
reverse
public static void reverse(long[] values, int n) Reverse the first n elements of the given array.- Parameters:
values- array to be reversedn- number of elements to reverse
-