Proper heapsort.