Java Quick Sort quickSortStringArray(String array[], int lo0, int hi0)

Here you can find the source of quickSortStringArray(String array[], int lo0, int hi0)

Description

Quick sort the given chunk of the array in place.

License

Open Source License

Parameter

Parameter Description
array The array to sort.
lo0 The low bound of the chunk of the array to sort.
hi0 The high bound of the array to sort.

Declaration

static void quickSortStringArray(String array[], int lo0, int hi0) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w w  w .  j  a  va  2s  .  c  o m*/
     * Quick sort the given chunk of the array in place.
     * @param array The array to sort.
     * @param lo0 The low bound of the chunk of the array to sort.
     * @param hi0 The high bound of the array to sort.
     */
    static void quickSortStringArray(String array[], int lo0, int hi0) {
        int lo = lo0;
        int hi = hi0;
        String mid = null;

        if (hi0 > lo0) {
            mid = array[(lo0 + hi0) / 2];
            while (lo <= hi) {
                while ((lo < hi0) && (array[lo].compareTo(mid) < 0))
                    ++lo;
                while ((hi > lo0) && (array[hi].compareTo(mid) > 0))
                    --hi;
                if (lo <= hi) {
                    String tmp = array[lo];
                    array[lo] = array[hi];
                    array[hi] = tmp;
                    ++lo;
                    --hi;
                }
            }
            if (lo0 < hi)
                quickSortStringArray(array, lo0, hi);
            if (lo < hi0)
                quickSortStringArray(array, lo, hi0);
        }
    }
}

Related

  1. quickSort2(int target[], int fromIndex, int length, int[] coSort)
  2. quickSortInt(int[] data, int[] dataIdx, int len)
  3. quickSortMaxToMin(int a[], int lo0, int hi0)
  4. quickSortReverse(String[] sortedCollection, int left, int right)
  5. quickSortReverso(double[] arr, int esquerda, int direita)