minor heapsort refactoring