heapsort now working as expected