Heapsort implementation using arrays for heap