Java Quick Sort quickSort(double[] array, int[] idx, int from, int to)

Here you can find the source of quickSort(double[] array, int[] idx, int from, int to)

Description

Quick sort procedure (ascending order)

License

Open Source License

Parameter

Parameter Description
array a parameter
idx a parameter
from a parameter
to a parameter

Declaration

public static void quickSort(double[] array, int[] idx, int from, int to) 

Method Source Code

//package com.java2s;
//  it under the terms of the GNU Lesser General Public License as published by

public class Main {
    /**// ww w  . ja  va2  s .  c  o m
     * Quick sort procedure (ascending order)
     * 
     * @param array
     * @param idx
     * @param from
     * @param to
     */
    public static void quickSort(double[] array, int[] idx, int from, int to) {
        if (from < to) {
            double temp = array[to];
            int tempIdx = idx[to];
            int i = from - 1;
            for (int j = from; j < to; j++) {
                if (array[j] <= temp) {
                    i++;
                    double tempValue = array[j];
                    array[j] = array[i];
                    array[i] = tempValue;
                    int tempIndex = idx[j];
                    idx[j] = idx[i];
                    idx[i] = tempIndex;
                }
            }
            array[to] = array[i + 1];
            array[i + 1] = temp;
            idx[to] = idx[i + 1];
            idx[i + 1] = tempIdx;
            quickSort(array, idx, from, i);
            quickSort(array, idx, i + 1, to);
        }
    }
}

Related

  1. quickSort( double[] array, int[] index, int left, int right)
  2. quickSort( float[] array, int[] index, int left, int right)
  3. quicksort(Comparable[] a)
  4. quicksort(double lista1[], int lista2[], int izq, int der)
  5. quickSort(double[] array, int low, int high)
  6. quicksort(double[] main, int[] index)
  7. quicksort(final double[] array, final int[] index)
  8. quicksort(final long[] data, final int left, final int right)
  9. quicksort(float[] a, int[] index, int left, int right)