Java Quick Sort quickSort(int[] source)

Here you can find the source of quickSort(int[] source)

Description

quick Sort

License

LGPL

Declaration

public static int[] quickSort(int[] source) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {

    public static int[] quickSort(int[] source) {
        return qsort(source, 0, source.length - 1);
    }/*from  w  w w  .  jav  a 2  s.  c  o  m*/

    private static int[] qsort(int source[], int low, int high) {
        int i, j, x;
        if (low < high) {
            i = low;
            j = high;
            x = source[i];
            while (i < j) {
                while (i < j && source[j] > x) {
                    j--;
                }
                if (i < j) {
                    source[i] = source[j];
                    i++;
                }
                while (i < j && source[i] < x) {
                    i++;
                }
                if (i < j) {
                    source[j] = source[i];
                    j--;
                }
            }
            source[i] = x;
            qsort(source, low, i - 1);
            qsort(source, i + 1, high);
        }
        return source;
    }
}

Related

  1. quicksort(int[] array)
  2. quickSort(int[] array)
  3. quickSort(int[] array, int lo0, int hi0)
  4. quickSort(int[] array, int[] index, int lo0, int hi0)
  5. quicksort(int[] source)
  6. quickSort(int[] target, int[] coSort)
  7. quickSort(int[] x)
  8. quickSort(int[] x)
  9. quickSort(short[] fireZoneInfo, int left, int right)