completed implementation of heapsort on an array of ints