Heap Sort
In short: heap sort turns the array itself into a heap, using no extra memory. First it builds a max-heap bottom-up, so the biggest value sits at index 0. Then it repeats one move: swap the root with the last unsorted slot, shrink the heap by one, and sift the new root down to fix the one violation that swap created. Each sift-down costs O(log n), and there are n of them, so the whole sort is O(n log n) time and O(1) extra space — but it is not stable: equal keys can come out in a different order than they went in.

Rank a batch of support tickets
Quarry's nightly job ranks a batch of support tickets by priority before anyone reads them, highest first. The tickets already sit in one array — no separate structure needed:
heap_sort builds ascending order, because each extraction moves the current
biggest value to the end. For "highest priority first", read the result
backwards, or flip every comparison to build a min-heap instead.
Watch the heap get built, then watch two extractions shrink it from the right:
Building the heap only fixes parent-child violations, working from the last parent up to the root — most of the array never moves.
Start at the last parent, index 1 (10). Its only child is index 3 (5) — no violation there. 5 cells. At index 1.
Extraction swaps the root into the shrinking heap's last slot, then sifts the new root back down. The sorted suffix on the right only ever grows.
This is already a valid max-heap: 9 beats both of its children, 5 and 7. 5 cells. At index 0.