opendap/src/main/java/opendap/dap/Util.java
static private void quickSort(String a[], int lo0, int hi0) {
        int lo = lo0;
        int hi = hi0;
        String mid;

        if (hi0 > lo0) {
            // Arbitrarily establishing partition element as the array midpoint */
            //Coverity[FB.IM_AVERAGE_COMPUTATION_COULD_OVERFLOW]
            mid = a[(lo0 + hi0) / 2];

            // loop through the array until indices cross
            while (lo <= hi) {
                // find the first element that is >= the partition element
                // starting from the left index.
                while ((lo < hi0) && (a[lo].compareTo(mid) < 0))
                    ++lo;

                // find an element that is <= the partition element
                // starting from the right index.
                while ((hi > lo0) && (a[hi].compareTo(mid) > 0))
                    --hi;

                // if the indexes have not crossed, swap
                if (lo <= hi) {
                    swap(a, lo, hi);
                    ++lo;
                    --hi;
                }
            }
            // If the right index has not reached the left side of array,
            // sort the left partition.
            if (lo0 < hi)
                quickSort(a, lo0, hi);

            // If the left index has not reached the right side of array,
            // sort the right partition.
            if (lo < hi0)
                quickSort(a, lo, hi0);
        }
    }
static private void quickSort(String a[], int lo0, int hi0) {
        int lo = lo0;
        int hi = hi0;
        String mid;

        if (hi0 > lo0) {
            // Arbitrarily establishing partition element as the array midpoint */
            //Coverity[FB.IM_AVERAGE_COMPUTATION_COULD_OVERFLOW]
            mid = a[(lo0 + hi0) / 2];

            // loop through the array until indices cross
            while (lo <= hi) {
                // find the first element that is >= the partition element
                // starting from the left index.
                while ((lo < hi0) && (a[lo].compareTo(mid) < 0))
                    ++lo;

                // find an element that is <= the partition element
                // starting from the right index.
                while ((hi > lo0) && (a[hi].compareTo(mid) > 0))
                    --hi;

                // if the indexes have not crossed, swap
                if (lo <= hi) {
                    swap(a, lo, hi);
                    ++lo;
                    --hi;
                }
            }
            // If the right index has not reached the left side of array,
            // sort the left partition.
            if (lo0 < hi)
                quickSort(a, lo0, hi);

            // If the left index has not reached the right side of array,
            // sort the right partition.
            if (lo < hi0)
                quickSort(a, lo, hi0);
        }
    }
static private void quickSort ( String a [ ] , int lo0 , int hi0 ) { int lo = lo0 ; int hi = hi0 ; String mid ; if ( hi0 > lo0 ) { // Arbitrarily establishing partition element as the array midpoint */ //Coverity[FB.IM_AVERAGE_COMPUTATION_COULD_OVERFLOW] mid = a [ ( lo0 + hi0 ) / 2 ] ; // loop through the array until indices cross while ( lo <= hi ) { // find the first element that is >= the partition element // starting from the left index. while ( ( lo < hi0 ) && ( a [ lo ] . compareTo ( mid ) < 0 ) ) ++ lo ; // find an element that is <= the partition element // starting from the right index. while ( ( hi > lo0 ) && ( a [ hi ] . compareTo ( mid ) > 0 ) ) -- hi ; // if the indexes have not crossed, swap if ( lo <= hi ) { swap ( a , lo , hi ) ; ++ lo ; -- hi ; } } // If the right index has not reached the left side of array, // sort the left partition. if ( lo0 < hi ) quickSort ( a , lo0 , hi ) ; // If the left index has not reached the right side of array, // sort the right partition. if ( lo < hi0 ) quickSort ( a , lo , hi0 ) ; } }
Internal recursive method to perform Quick Sort on name array.

@param a   an array of <code>String</code>.
@param lo0 the low index to sort.
@param hi0 the high index to sort.
Internal recursive method to perform Quick Sort on name array .