Java Utililty Methods Array Sort

List of utility methods to do Array Sort

Description

The list of methods to do Array Sort are organized into topic(s).

Method

voidquickSort(int[] arr, int startIndex, int endIndex)
quick Sort
System.out.println(Arrays.toString(arr));
int pivotIndex = (startIndex + endIndex) / 2;
int i = startIndex;
int j = endIndex;
while (!(i > j)) {
    while (arr[i] < arr[pivotIndex])
        i++;
    while (arr[j] > arr[pivotIndex])
...
voidradixSort(int[] vs)
radix Sort
int n = vs.length;
int[] us = new int[n];
int[] num = new int[1 << 8];
for (int i = 0; i < n; i++)
    vs[i] ^= 1 << 31;
for (int i = 0; i < 32; i += 8) {
    Arrays.fill(num, 0);
    for (int j = 0; j < n; j++) {
...
voidselectionSort(int[] arr)
selection Sort
System.out.println(Arrays.toString(arr));
int counter = 0;
boolean swapRequired = false;
for (int i = 0; i < arr.length - 1; i++) {
    int minArrIndex = i;
    swapRequired = false;
    for (int j = i + 1; j < arr.length; j++) {
        if (arr[j] < arr[minArrIndex]) {
...
intsort(final Item[] values, final Item[] auxiliary, final int first, final int last)
sort
if (first >= last)
    return 0;
final int middle = first + (last - first) / 2;
int numberOfInversions = sort(values, auxiliary, first, middle);
numberOfInversions += sort(values, auxiliary, middle + 1, last);
numberOfInversions += merge(values, auxiliary, first, middle, last);
return numberOfInversions;
int[]sort( float[] array)
Sorts a given array of floats in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array.
int[] index = new int[array.length];
for (int i = 0; i < index.length; i++)
    index[i] = i;
array = array.clone();
quickSort(array, index, 0, array.length - 1);
return index;
voidsort(byte[] b, int pos)
sort
byte[] tmp = new byte[pos];
System.arraycopy(b, 0, tmp, 0, pos);
System.arraycopy(b, pos, b, 0, b.length - pos);
System.arraycopy(tmp, 0, b, b.length - pos, pos);
double[]sort(double s[], int idx[])
sort
int D = s.length;
double a[] = new double[D];
for (int i = 0; i < D; i++) {
    a[i] = s[i];
    idx[i] = i;
for (int i = 0; i < D - 1; i++) {
    for (int j = D - 1; j > i; j--)
...
voidsort(double[] a, int[] b)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays.
mergesort(a, b, 0, a.length - 1);
voidsort(double[] coords1, int length1, double[] coords2, int length2, int[] array)
sort
int temp;
int length = length1 + length2;
double x1, y1, x2, y2;
for (int i = 1; i < length; i++) {
    if (array[i - 1] < length1) {
        x1 = coords1[2 * array[i - 1]];
        y1 = coords1[2 * array[i - 1] + 1];
    } else {
...
voidsort(double[] data)
sort
if (data == null) {
    return;
Arrays.sort(data);