Sort an array using binary heap.