Here you can find the source of quickSort(T[] array, int[] index, int left, int right)
private static <T extends Comparable<? super T>> void quickSort(T[] array, int[] index, int left, int right)
//package com.java2s; //License from project: Open Source License public class Main { private static <T extends Comparable<? super T>> void quickSort(T[] array, int[] index, int left, int right) { if (left < right) { int middle = partition(array, index, left, right); quickSort(array, index, left, middle); quickSort(array, index, middle + 1, right); }// ww w . j ava 2 s .c o m } private static void quickSort(/* @non_null@ */double[] array, /* @non_null@ */int[] index, int left, int right) { if (left < right) { int middle = partition(array, index, left, right); quickSort(array, index, left, middle); quickSort(array, index, middle + 1, right); } } private static void quickSort(/* @non_null@ */int[] array, /* @non_null@ */int[] index, int left, int right) { if (left < right) { int middle = partition(array, index, left, right); quickSort(array, index, left, middle); quickSort(array, index, middle + 1, right); } } private static <T extends Comparable<? super T>> int partition(T[] array, int[] index, int l, int r) { T pivot = array[index[(l + r) / 2]]; int help; while (l < r) { while (array[index[l]].compareTo(pivot) < 0 && l < r) { l++; } while (array[index[r]].compareTo(pivot) > 0 && l < r) { r--; } if (l < r) { help = index[l]; index[l] = index[r]; index[r] = help; l++; r--; } } if (l == r && array[index[r]].compareTo(pivot) > 0) { r--; } return r; } private static int partition(double[] array, int[] index, int l, int r) { double pivot = array[index[(l + r) / 2]]; int help; while (l < r) { while ((array[index[l]] < pivot) && (l < r)) { l++; } while ((array[index[r]] > pivot) && (l < r)) { r--; } if (l < r) { help = index[l]; index[l] = index[r]; index[r] = help; l++; r--; } } if ((l == r) && (array[index[r]] > pivot)) { r--; } return r; } private static int partition(int[] array, int[] index, int l, int r) { double pivot = array[index[(l + r) / 2]]; int help; while (l < r) { while ((array[index[l]] < pivot) && (l < r)) { l++; } while ((array[index[r]] > pivot) && (l < r)) { r--; } if (l < r) { help = index[l]; index[l] = index[r]; index[r] = help; l++; r--; } } if ((l == r) && (array[index[r]] > pivot)) { r--; } return r; } }