Heap sort works by visualizing elements of an array as a complete binary tree called a heap. A max-heap has all nodes greater than their children, with the largest element at the root. To sort, the root element is removed and placed at the end of the array, and the heap is reorganized to maintain the max-heap property, repeating until sorted.