heap and heapsort implementation, and small changes to bitonic tour optimization to use the new heapsort