Master SortingAlgorithms Visually
Understand how sorting algorithms work with interactive visualizations. Compare performance and learn complexity analysis.
Choose Your AlgorithmStart Visualizing
Click on any algorithm card to see it in action with interactive step-by-step visualization
Quick Sort
Fast divide-and-conquer algorithm, one of the most efficient general-purpose sorting algorithms.
O(n log n)O(n²)Merge Sort
Guaranteed O(n log n) performance with stable sorting. Predictable and reliable.
O(n log n)O(n log n)Heap Sort
In-place sorting with guaranteed O(n log n) performance using heap data structure.
O(n log n)O(n log n)Bubble Sort
Simple comparison-based algorithm, good for educational purposes and small datasets.
O(n²)O(n²)Insertion Sort
Efficient for small datasets and nearly sorted data. Simple and adaptive.
O(n²)O(n²)Selection Sort
Simple selection-based algorithm with minimal memory writes.
O(n²)O(n²)Shell Sort
Improved insertion sort using gap sequences for better performance.
O(n log n)O(n²)Counting Sort
Non-comparison based linear time sorting for integer ranges.
O(n + k)O(n + k)Radix Sort
Processes digits from least to most significant for fixed-length integers.
O(d(n + k))O(d(n + k))Bucket Sort
Distributes elements into buckets for uniformly distributed data.
O(n + k)O(n²)Tim Sort
Hybrid algorithm used in Python and Java, excellent for real-world data.
O(n log n)O(n log n)Cocktail Sort
Bidirectional bubble sort, slightly better than standard bubble sort.
O(n²)O(n²)Comb Sort
Improvement over bubble sort by eliminating turtles (small values near end).
O(n²/2ᵖ)O(n²)Gnome Sort
Simple sorting algorithm similar to insertion sort but moving elements to proper place by swapping.
O(n²)O(n²)Cycle Sort
Minimizes the number of memory writes, good when writing to memory is expensive.
O(n²)O(n²)Pancake Sort
Only uses flip operation (reversing elements from beginning to a position).
O(n²)O(n²)Stooge Sort
Recursive sorting algorithm with poor efficiency, mainly of academic interest.
O(n^2.7)O(n^2.7)Bogo Sort
Extremely inefficient algorithm that randomly permutes elements until sorted.
O((n+1)!)O(∞)Each algorithm includes interactive visualization, code implementation, and complexity analysis
All Sorting AlgorithmsDetailed Overview
Explore 18 sorting algorithms with complexity analysis, pros & cons, and use cases
Complete AlgorithmComparison Table
Compare all 18 sorting algorithms at a glance
| Algorithm | Category | Best | Average | Worst | Space | Stable | In-Place |
|---|---|---|---|---|---|---|---|
| Quick Sort | Comparison | O(n log n) | O(n log n) | O(n²) | O(log n) | ||
| Merge Sort | Comparison | O(n log n) | O(n log n) | O(n log n) | O(n) | ||
| Heap Sort | Comparison | O(n log n) | O(n log n) | O(n log n) | O(1) | ||
| Tim Sort | Hybrid | O(n) | O(n log n) | O(n log n) | O(n) | ||
| Bubble Sort | Comparison | O(n) | O(n²) | O(n²) | O(1) | ||
| Insertion Sort | Comparison | O(n) | O(n²) | O(n²) | O(1) | ||
| Selection Sort | Comparison | O(n²) | O(n²) | O(n²) | O(1) | ||
| Shell Sort | Comparison | O(n log n) | O(n^1.5) | O(n²) | O(1) | ||
| Cocktail Sort | Comparison | O(n) | O(n²) | O(n²) | O(1) | ||
| Comb Sort | Comparison | O(n log n) | O(n²/2ᵖ) | O(n²) | O(1) | ||
| Gnome Sort | Comparison | O(n) | O(n²) | O(n²) | O(1) | ||
| Cycle Sort | Comparison | O(n²) | O(n²) | O(n²) | O(1) | ||
| Pancake Sort | Comparison | O(n) | O(n²) | O(n²) | O(1) | ||
| Stooge Sort | Comparison | O(n^2.7) | O(n^2.7) | O(n^2.7) | O(n) | ||
| Bogo Sort | Randomized | O(n) | O((n+1)!) | O(∞) | O(1) | ||
| Counting Sort | Non-Comparison | O(n+k) | O(n+k) | O(n+k) | O(k) | ||
| Radix Sort | Non-Comparison | O(d(n+k)) | O(d(n+k)) | O(d(n+k)) | O(n+k) | ||
| Bucket Sort | Non-Comparison | O(n+k) | O(n+k) | O(n²) | O(n+k) |
Legend & Notes
n: Number of elements
k: Range of input values
d: Number of digits
p: Number of increments
Stable: Maintains relative order of equal elements
In-Place: Requires O(1) or O(log n) extra space
∞: Unbounded (may never terminate)