DataStructures
Class Sort

java.lang.Object
  |
  +--DataStructures.Sort

public class Sort
extends java.lang.Object

A class providing static array sorting routines

Author:
Peter Williams
See Also:
Comparable

Method Summary
static void heapSort(java.lang.Comparable[] a, int n)
          Sorts an array a[0..n-1] of Comparable objects in ascending order using the Heapsort algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

heapSort

public static final void heapSort(java.lang.Comparable[] a,
                                  int n)
Sorts an array a[0..n-1] of Comparable objects in ascending order using the Heapsort algorithm. The array is replaced on output by its sorted rearrangement.
Parameters:
a - the array to sort
n - the number of elements sorted, elements a[n] onwards are ignored
Throws:
ArrayIndexOutOfBoundsException - if n is greater than the array length.