Elementary comparison-based sorts: bubble, selection, insertion, Shell, comb, cycle, and curiosity sorts.
| index | slug | name |
|---|---|---|
| 151 | bubble-sort | Bubble Sort |
| 152 | optimized-bubble-sort | Optimized Bubble Sort |
| 153 | cocktail-shaker-sort | Cocktail Shaker Sort |
| 154 | odd-even-sort | Odd Even Sort |
| 155 | gnome-sort | Gnome Sort |
| 156 | selection-sort | Selection Sort |
| 157 | stable-selection-sort | Stable Selection Sort |
| 158 | double-selection-sort | Double Selection Sort |
| 159 | insertion-sort | Insertion Sort |
| 160 | binary-insertion-sort | Binary Insertion Sort |
| 161 | shell-sort | Shell Sort |
| 162 | shell-sort-shell-gaps | Shell Sort with Shell Gaps |
| 163 | shell-sort-hibbard-gaps | Shell Sort with Hibbard Gaps |
| 164 | shell-sort-sedgewick-gaps | Shell Sort with Sedgewick Gaps |
| 165 | comb-sort | Comb Sort |
| 166 | cycle-sort | Cycle Sort |
| 167 | pancake-sort | Pancake Sort |
| 168 | stooge-sort | Stooge Sort |
| 169 | slow-sort | Slow Sort |
| 170 | bead-sort | Bead Sort |
| 171 | strand-sort | Strand Sort |
| 172 | library-sort | Library Sort |
| 173 | patience-sort | Patience Sort |
| 174 | tree-sort | Tree Sort |
| 175 | tournament-sort | Tournament Sort |
| 176 | smoothsort | Smoothsort |
| 177 | weak-heap-sort | Weak Heap Sort |
| 178 | cartesian-tree-sort | Cartesian Tree Sort |
| 179 | bingo-sort | Bingo Sort |
| 180 | exchange-sort | Exchange Sort |
Optimized Bubble SortBubble sort with early termination when no swaps occur, reducing unnecessary passes on nearly sorted data.
Cocktail Shaker SortA bidirectional variant of bubble sort that alternates passes from left to right and right to left.
Odd Even SortA variation of bubble sort that alternates between comparing odd-even and even-odd index pairs.
Gnome SortA simple sorting algorithm that moves elements backward when out of order, similar to insertion sort with swaps.
Selection SortRepeatedly select the minimum element from the unsorted portion and place it at the beginning.
Stable Selection SortA stable variant of selection sort that preserves the relative order of equal elements by shifting instead of swapping.
Double Selection SortSelect both minimum and maximum elements in each pass and place them at the beginning and end.
Insertion SortBuild a sorted sequence by inserting each element into its correct position.
Binary Insertion SortInsertion sort that uses binary search to find the insertion position, reducing comparisons.
Shell SortGeneralization of insertion sort that compares elements at a gap, reducing long-distance inversions early.
Shell Sort with Shell GapsShell sort using the original gap sequence n/2, n/4, ..., 1.
Shell Sort with Hibbard GapsShell sort using Hibbard gap sequence 1, 3, 7, 15, ..., improving over simple halving.
Shell Sort with Sedgewick GapsShell sort using Sedgewick gap sequence for improved practical performance.
Comb SortA bubble-sort variant that compares elements at a shrinking gap to remove long-distance inversions early.
Cycle SortMinimizes writes by placing each element directly into its correct position using cycles.
Pancake SortSort by repeatedly flipping prefixes to move the maximum element to its correct position.
Stooge SortA recursive sorting algorithm with extremely poor performance based on overlapping subproblems.
Slow SortA deliberately inefficient recursive sorting algorithm based on divide and conquer followed by maximum placement.
Bead SortSort non-negative integers by simulating gravity on beads arranged in columns.
Strand SortExtract increasing subsequences and merge them to form a sorted sequence.
Library SortAn insertion-based sorting algorithm that leaves gaps between elements to reduce shifting.
Patience SortSort by building piles using patience card game rules and then merging them.
Tree SortInsert all elements into a binary search tree, then traverse the tree in sorted order.
Tournament SortSort by repeatedly selecting the minimum element using a tournament tree.
SmoothsortAn adaptive in-place comparison sort based on Leonardo heaps.
Weak Heap SortA variant of heapsort using weak heaps with fewer comparisons.
Cartesian Tree SortSort by building a Cartesian tree and extracting elements via inorder traversal.
Bingo SortRepeatedly place all occurrences of the current minimum value before moving to the next distinct value.
Exchange SortA simple quadratic sorting algorithm that compares all pairs and swaps out-of-order elements.
Bubble SortRepeatedly swap adjacent elements that are out of order until the sequence becomes sorted.