Java Quick Sort quicksort(String a[], int lo0, int hi0)

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

Description

quicksort

License

Open Source License

Declaration

private static void quicksort(String a[], int lo0, int hi0) 

Method Source Code

//package com.java2s;
/*//from  ww w  . ja v  a2s. c  o m
 * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. Please refer to the file "copyright.html"
 * for further important copyright and licensing information.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

public class Main {
    private static void quicksort(String a[], int lo0, int hi0) {
        int lo = lo0;
        int hi = hi0;
        if (lo >= hi) {
            return;
        }
        String mid = a[(lo + hi) / 2];
        while (lo < hi) {
            while (lo < hi && a[lo].compareTo(mid) < 0) {
                lo++;
            }
            while (lo < hi && a[hi].compareTo(mid) > 0) {
                hi--;
            }
            if (lo < hi) {
                String T = a[lo];
                a[lo] = a[hi];
                a[hi] = T;
            }
        }
        if (hi < lo) {
            int T = hi;
            hi = lo;
            lo = T;
        }
        quicksort(a, lo0, lo);
        quicksort(a, lo == lo0 ? lo + 1 : lo, hi0);
    }
}

Related

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