Heap Sort

Build a heap from the list, then repeatedly pull out the largest element to sort in place in O(n log n).

Related concepts

TopicDescription
Bubble SortRepeatedly swap neighboring out-of-order elements until the whole list is sorted, simple but slow on large lists.
Merge SortSplit the list in half, sort each half, then merge them back together in order, giving reliable O(n log n) time.
Quick SortPick a pivot, move smaller elements left and larger ones right, then repeat on each side to sort in place.
Insertion SortBuild the sorted list one element at a time, inserting each new element into its correct position as you go.
Selection SortRepeatedly find the smallest remaining element and move it into place, simple to write but slow on large lists.
Counting SortCount how many times each value appears, then rebuild the list in order, sorting in O(n) when values fall in a small range.