HeapSort implementation