Heapsorting arrays