org.apache.datasketches.tdigest

## Class Sort

- java.lang.Object
- - org.apache.datasketches.tdigest.Sort

    public final class Sort
    extends Object

Specialized sorting algorithm that can sort one array and permute another array the same way.

### Constructor Summary

Constructors
Constructor and Description
`Sort()`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `reverse(double[] values, int n)` Reverse the first n elements of the given array.
`static void` `reverse(long[] values, int n)` Reverse the first n elements of the given array.
`static void` `stableSort(double[] keys, long[] values, int n)` Stable sort two arrays.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Sort

    public Sort()

### Method Detail

#### stableSort

    public static void stableSort(double[] keys,
                                  long[] values,
                                  int n)

Stable sort two arrays. The first array is sorted while the second array is permuted the same way.

Parameters:
  `keys` - array to be sorted
  `values` - array to be permuted the same way
  `n` - 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 reversed
  `n` - 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 reversed
  `n` - number of elements to reverse