Step through heapify and the repeated root-to-end swaps of heapsort.
Build a max-heap, then swap the root to the end and sift down.
Operations for n elements.
Not stable · In place
Build a max-heap, then repeatedly swap the root to the end.
Heapsort done.