public class Sort extends Object
Sort class contains static utilities for sorting
arrays of primitive values with respect to primitive comparators.
| Modifier and Type | Class and Description |
|---|---|
static interface |
Sort.CompareInt
The
CompareInt interface is for comparing
pairs of integers. |
| Modifier and Type | Field and Description |
|---|---|
static Sort.CompareInt |
NATURAL_INT_COMPARE
This constant implements the
CompareInt interface using
the natural order of integers. |
| Modifier and Type | Method and Description |
|---|---|
static void |
isort(int[] x,
Sort.CompareInt compare)
Sort the specified array of integers according to the
specified comparator using insertion sort.
|
static void |
qsort(int[] x,
Sort.CompareInt compare)
Sort the specified array of integers according to the
specified comparator using quicksort.
|
static void |
swap(int[] xs,
int i,
int j)
Swap the values for the array at the specified indexes.
|
public static final Sort.CompareInt NATURAL_INT_COMPARE
CompareInt interface using
the natural order of integers.public static void isort(int[] x,
Sort.CompareInt compare)
x - Array of ints to sort.compare - Comparator to use for sorting.public static void qsort(int[] x,
Sort.CompareInt compare)
x - Array of ints to sort.compare - Comparator to use for sorting.public static void swap(int[] xs,
int i,
int j)
xs - Array of elements.i - Index of first element in array.j - Index of second element in array.IndexOutOfBoundsException - If either index is out
of bounds for the arrayCopyright © 2019 Alias-i, Inc.. All rights reserved.