Heapsort
Time complexity: O(n log n).
Result
Examples
How it works
Heapsort arranges the list as a max-heap, then repeatedly swaps the largest value to the end and repairs the heap. It sorts in place with no extra memory.
When to use it
Guaranteed O(n log n) with no extra memory, when stability does not matter.