Write a function that takes in an array of integers and returns a sorted version of that array using the Heap Sort algorithm.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to selection sort where we first find the maximum element and place the maximum element at the end. We repeat the same process for the remaining elements.