public void heapSort(T[] array) {
		size = array.length;
		heapArray = (T[]) new Comparable[size];
		System.arraycopy(array, 0, heapArray, 0, size);
		for (int k = size / 2; k > 0; k--) {
			percolatingDown(k);
		}
		for (int i = size; i >= 0; i--) {
			// Swap the top node and the node at i's location, then percolate
			// down.
			T tmp = heapArray[i];
			heapArray[i] = heapArray[1];
			heapArray[1] = tmp;
			size--;
			percolatingDown(1);
		}
		for (int k = 0; k < heapArray.length; k++)
			array[k] = heapArray[heapArray.length - k];
	}