AlgoViz

Heap sort

medium 18 min

Heap sort turns the array into a max-heap in O(n), then repeatedly swaps the root (the maximum) to the end and sifts the new root down in O(log n).