Here you can find the source of quickSort(double[] array, int[] idx, int from, int to)
Parameter | Description |
---|---|
array | a parameter |
idx | a parameter |
from | a parameter |
to | a parameter |
public static void quickSort(double[] array, int[] idx, int from, int to)
//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); } } }