Java List Sort quickSort(Comparable[] list, int min, int max)

Here you can find the source of quickSort(Comparable[] list, int min, int max)

Description

Performs a quick sort on the given array of Comparable objects between the min and maximum range.

License

Open Source License

Declaration

public static void quickSort(Comparable[] list, int min, int max) 

Method Source Code

//package com.java2s;
/**//from  w w w. ja v a  2  s  .c om
 * com.mckoi.util.SortUtil  29 Mar 1998
 *
 * Mckoi SQL Database ( http://www.mckoi.com/database )
 * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * Version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License Version 2 for more details.
 *
 * You should have received a copy of the GNU General Public License
 * Version 2 along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Change Log:
 * 
 * 
 */

import java.util.Arrays;

public class Main {
    /**
     * Performs a quick sort on the given array of Comparable objects between
     * the min and maximum range.  It changes the array to the new sorted order.
     */
    public static void quickSort(Comparable[] list, int min, int max) {
        Arrays.sort(list, min, max + 1);

        //    int left = min;
        //    int right = max;
        //
        //    if (max > min) {
        //      Comparable mid = list[(min + max) / 2];
        //      while (left < right) {
        //        while (left < max && list[left].compareTo(mid) < 0) {
        //          ++left;
        //        }
        //        while (right > min && list[right].compareTo(mid) > 0) {
        //          --right;
        //        }
        //        if (left <= right) {
        //          if (left != right) {
        //            Comparable t = list[left];
        //            list[left] = list[right];
        //            list[right] = t;
        //          }
        //
        //          ++left;
        //          --right;
        //        }
        //
        //      }
        //
        //      if (min < right) {
        //        quickSort(list, min, right);
        //      }
        //      if (left < max) {
        //        quickSort(list, left, max);
        //      }
        //
        //    }
    }

    /**
     * Performs a quick sort on the given array of Comparable objects.
     * It changes the array to the new sorted order.
     */
    public static void quickSort(Comparable[] obs) {
        quickSort(obs, 0, obs.length - 1);
    }
}

Related

  1. maximum(List sortedDataAscendingOrder)
  2. mergeLong(List l1, List l2, boolean sort)
  3. mergeSort(List m)
  4. mergeSort(List list)
  5. mergeSortedLists(List dest, List[] src, boolean removeDuplicates)
  6. removeSortByColumnName(List sortProperty, List ascending, String columnName)
  7. removeSortColumns(List selectColumns, List sorts, List ascending)
  8. removeSortColumns(List selectColumns, List sorts, List ascending)
  9. searchSorted(List a, double v)