Amazon interview question

Implement the Heap Sort function