Java Quick Sort quickSort(String[] str, int low, int high)

Here you can find the source of quickSort(String[] str, int low, int high)

Description

quick Sort

License

Open Source License

Declaration

public static void quickSort(String[] str, int low, int high) 

Method Source Code

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

import java.text.Collator;

public class Main {
    public static Collator collator = Collator.getInstance();

    public static void quickSort(String[] str, int low, int high) {
        if (low >= high)
            return;

        String pivot = str[low];//from   w  w  w . j a  v  a 2  s  .c  o m
        int slow = low - 1, shigh = high + 1;

        while (true) {
            do
                shigh--;
            while (collator.compare(str[shigh], pivot) > 0);
            do
                slow++;
            while (collator.compare(pivot, str[slow]) > 0);
            if (slow >= shigh)
                break;

            String temp = str[slow];
            str[slow] = str[shigh];
            str[shigh] = temp;
        }

        quickSort(str, low, shigh);
        quickSort(str, shigh + 1, high);
    }
}

Related

  1. quickSort(int[] x)
  2. quickSort(int[] x)
  3. quickSort(short[] fireZoneInfo, int left, int right)
  4. quicksort(String a[], int lo0, int hi0)
  5. quickSort(String a[], int lo0, int hi0)
  6. quickSort(String[] strings, int begin, int length)
  7. quickSort(T[] array, int[] index, int left, int right)
  8. quickSort1(double array[], int low, int n)
  9. quickSort1(int target[], int fromIndex, int length, int[] coSort)