Build a max-heap from the array, then repeatedly extract the maximum to the end. Two phases: heapify, then extract.
Time: O(n log n) guaranteed
Space: O(1) in-place
Stable: No
Top: bar chart. Bottom: binary tree view showing heap structure and sift-down paths.