Class Sort

java.lang.Object
  extended by Sort

public class Sort
extends java.lang.Object

Class Sort contains utility sort functions.

 List of Methods
=================== quickSort(int[]) - quicksort a list of integers. bubbleSort(String[]) - bubble sort a list of Strings. bubbleSortIndex(String[]) - bubble sort a String[] and return sort index. bubbleSortIndex(double[]) - bubble sort a double[] and return sort index. bubbleSortIndex(float[]) - bubble sort a float[] and return sort index. bubbleSortIndex(int[]) - bubble sort a int[] and return sort index.

This code is available at the HTMLtools project on SourceForge at http://htmltools.sourceforge.org/ under the "Common Public License Version 1.0" http://www.opensource.org/licenses/cpl1.0.php.

It was derived and refactored from the open source MAExplorer (http://maexplorer.sourceforge.org/), and Open2Dprot (http://Open2Dprot.sourceforge.net/) Table modules.

$Date: 2009/067/03 11:45:56 $ $Revision: 1.28 $
Copyright 2008, 2009 by Peter Lemkin E-Mail: lemkin@users.sourceforge.net http://lemkingroup.com/


Constructor Summary
Sort()
          Sort() - Constructor
 
Method Summary
static java.lang.String[] bubbleSort(java.lang.String[] data, int len)
          bubbleSort() - Sort String array via bubble sort w/len
static int[] bubbleSortIndex(double[] data, int len, boolean ascending)
          bubbleSortIndex() - sort copy of double[0:len-1] data with bubble sort, return index[].
static int[] bubbleSortIndex(float[] data, int len, boolean ascending)
          bubbleSortIndex() - sort copy of float[0:len-1] data with bubble sort, return index[].
static int[] bubbleSortIndex(int[] data, int len, boolean ascending)
          bubbleSortIndex() - sort copy of int[0:len-1] data with bubble sort, return index[].
static int[] bubbleSortIndex(java.lang.String[] data, int len, boolean ascending)
          bubbleSortIndex() - sort copy of String[0:len-1] data with bubble sort, return index[].
static void quickSort(int[] a, int lo0, int hi0)
          quickSort() - sort the int[] array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sort

public Sort()
Sort() - Constructor

Method Detail

quickSort

public static void quickSort(int[] a,
                             int lo0,
                             int hi0)
quickSort() - sort the int[] array. Based on QuickSort method by James Gosling from Sun's SortDemo applet

Parameters:
a - array of data to sort
lo0 - lower bound of array
hi0 - uppper bound of array

bubbleSort

public static java.lang.String[] bubbleSort(java.lang.String[] data,
                                            int len)
bubbleSort() - Sort String array via bubble sort w/len

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
Returns:
the new sorted string[] array

bubbleSortIndex

public static int[] bubbleSortIndex(java.lang.String[] data,
                                    int len,
                                    boolean ascending)
bubbleSortIndex() - sort copy of String[0:len-1] data with bubble sort, return index[]. Do NOT actually sort the original data[].

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
ascending - sort if true
Returns:
the index[] of the sorted data

bubbleSortIndex

public static int[] bubbleSortIndex(double[] data,
                                    int len,
                                    boolean ascending)
bubbleSortIndex() - sort copy of double[0:len-1] data with bubble sort, return index[]. Do NOT actually sort the original data[].

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
ascending - sort if true
Returns:
the index[] of the sorted data

bubbleSortIndex

public static int[] bubbleSortIndex(float[] data,
                                    int len,
                                    boolean ascending)
bubbleSortIndex() - sort copy of float[0:len-1] data with bubble sort, return index[]. Do NOT actually sort the original data[].

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
ascending - sort if true
Returns:
the index[] of the sorted data

bubbleSortIndex

public static int[] bubbleSortIndex(int[] data,
                                    int len,
                                    boolean ascending)
bubbleSortIndex() - sort copy of int[0:len-1] data with bubble sort, return index[]. Do NOT actually sort the original data[].

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
ascending - sort if true
Returns:
the index[] of the sorted data