implemented HeapSort (with a max heap)