Skip to content
Back to categories

Sorting

Algorithms that arrange data into a defined order.

Sorting algorithms reorder records, numbers, strings, or objects so later work can scan, compare, search, or present the data more easily.

SortingO(n^2)

Bubble Sort

Sorts a list by repeatedly swapping neighboring items that are out of order.

BeginnerCoreNo formula2 links
Comparison SortIn PlaceStable SortClassic
SortingO(n^2)

Insertion Sort

Sorts a list by inserting each item into the correct position within the already-sorted prefix.

BeginnerFoundationNo formula7 links
Comparison SortIn PlaceStable SortClassic
SortingO(n^2)

Selection Sort

Sorts by repeatedly selecting the smallest remaining item.

BeginnerCoreNo formula4 links
Comparison SortIn PlaceClassic
SortingO(n log n)

Merge Sort

Sorts a list by recursively sorting halves and merging the sorted results.

IntermediateFoundationNo formula11 links
Comparison SortDivide and ConquerStable SortRecursion
SortingO(n log n)

Quick Sort

Sorts a list by partitioning values around a pivot and recursively sorting each side.

IntermediateFoundationNo formula6 links
Comparison SortDivide and ConquerIn PlaceRecursion
SortingO(n log n)

Heap Sort

Sorts a list by building a heap and repeatedly removing the highest-priority item.

IntermediateFoundationNo formula5 links
Comparison SortPriority QueueIn PlaceClassic
SortingO(n + k)

Counting Sort

Sorts integer values by counting how many times each value appears.

BeginnerCoreNo formula3 links
Integer DataStable SortClassic
SortingO(d(n + k))

Radix Sort

Sorts values by processing one digit or character position at a time.

IntermediateCoreNo formula4 links
Integer DataStable SortClassic
SortingO(n + k)

Bucket Sort

Sorts by distributing values into buckets and sorting within each bucket.

IntermediateCoreNo formula2 links
Bucket BasedInteger DataStable Sort
SortingO(n^1.5)

Shell Sort

Sorts by comparing items far apart, then gradually reducing the gap.

IntermediateCoreNo formula1 links
Comparison SortIn PlaceAdaptive Sort
SortingO(n log n)

Tim Sort

Sorts by detecting existing ordered runs and merging them with safeguards for real-world data.

AdvancedCoreNo formula3 links
Comparison SortStable SortAdaptive SortHybrid Sort
SortingO(n log n)

External Sort

Sorts data sets that are too large to fit in memory by sorting chunks and merging them from disk.

AdvancedExtendedNo formula1 links
SortingExternal MemoryDivide and Conquer
SortingO(n log n)

Parallel Merge Sort

Sorts large collections by splitting merge sort work across workers and merging sorted partitions.

IntermediateCoreNo formula2 links
SortingDivide and ConquerStable SortLoad Balancing
SortingO(n log n)

Bitonic Sort

Bitonic Sort sorts with a fixed comparison network suited to parallel execution.

IntermediateCoreNo formula1 links
Sorting
SortingO(n log n)

Odd-Even Sort

Odd-Even Sort sorts with a fixed comparison network suited to parallel execution.

IntermediateCoreNo formula1 links
Sorting
SortingO(n log n)

Odd-Even Merge Sort

Odd-Even Merge Sort sorts with a fixed comparison network suited to parallel execution.

IntermediateCoreNo formula1 links
Sorting
SortingO(n log n)

Pancake Sort

Pancake Sort orders records with a named compare, partition, or distribution strategy.

IntermediateExtendedNo formula2 links
Sorting
SortingO(n log n)

Cycle Sort

Cycle Sort orders records with a named compare, partition, or distribution strategy.

IntermediateExtendedNo formula2 links
Sorting
SortingO(n log n)

Smoothsort

Smoothsort orders records with a named compare, partition, or distribution strategy.

IntermediateExtendedNo formula2 links
Sorting
SortingO(n log n)

Tournament Sort

Tournament Sort orders records with a named compare, partition, or distribution strategy.

IntermediateExtendedNo formula2 links
Sorting
SortingO(n log n)

Library Sort

Library Sort orders records with a named compare, partition, or distribution strategy.

IntermediateExtendedNo formula1 links
Sorting
SortingO(n log n)

Patience Sorting

Patience Sorting orders records with a named compare, partition, or distribution strategy.

IntermediateExtendedNo formula1 links
Sorting
SortingO(n log n)

American Flag Sort

American Flag Sort orders records with a named compare, partition, or distribution strategy.

IntermediateExtendedNo formula1 links
Sorting
SortingO(n log n)

Sample Sort

Sample Sort orders large or partitioned data by coordinating smaller sorted pieces.

IntermediateCoreNo formula1 links
Sorting
SortingO(n log n)

Natural Merge Sort

Natural Merge Sort addresses adaptive sorting by detecting existing sorted runs and merging them.

IntermediateCoreNo formula3 links
Sorting
SortingO(n log n)

Flashsort

Flashsort addresses distribution sorting by classifying elements into buckets by estimated value distribution.

IntermediateExtendedNo formula3 links
Sorting