Comparison sort

Also known as: Comparison-based sort

A comparison sort orders elements using only pairwise comparisons ($a < b$, $a \le b$, …). It does not inspect bit patterns or digit ranks the way counting or radix sorts do.

In the decision-tree model, any comparison sort needs $\Omega(n \log n)$ comparisons in the worst case to sort $n$ distinct keys. That is why “better than $n \log n$” for arbitrary comparable keys usually means a different model (integers in a range, strings with radix structure), not a smarter compare.

Merge sort, heapsort, quicksort, and the $O(n^2)$ elementary sorts are all comparison sorts.

← Back to CS Glossary