Sorting
Comparison sorts, linear-time sorts and the hybrids used in practice.
Repeatedly swap adjacent out-of-order pairs so the largest remaining element bubbles to the end each pass.
Repeatedly select the minimum of the unsorted suffix and swap it into place; exactly n−1 swaps.
Build a sorted prefix by inserting each new element into its correct place among the ones before it.
Split the array in half, sort each half recursively, then merge the two sorted halves in linear time.
Pick a pivot, partition elements into smaller and larger sides, and recursively sort each side.
Build a max-heap in place, then repeatedly swap the root to the end and restore the heap.
Count occurrences of each key in a small integer range, then place elements by prefix sums — linear time, no comparisons.
Sort integers digit by digit from least significant to most, using a stable counting sort per digit.
Distribute elements into buckets by value range, sort each bucket, and concatenate — linear on uniform data.
Insertion sort over elements h apart with a shrinking gap sequence, finishing with a plain insertion sort.
Adaptive, stable hybrid of merge sort and insertion sort that exploits existing sorted runs; the default sort in Python and Java.