Builds a max-heap from the array so the root always holds the largest unsorted value, then repeatedly extracts the root by swapping it with the last unsorted element, shrinks the heap boundary by one, and restores the heap property via sift-down.
In-place and O(n log n) in the worst case with no extra memory, but not stable and not adaptive, it performs the same amount of work on every input regardless of its existing order.