My first implementation of heapsort