Sorting Visualizer
Watch different sorting algorithms organize data in real-time.
Algorithms
- Bubble Sort O(n²) - Repeatedly swaps adjacent out-of-order elements
- Selection Sort O(n²) - Finds minimum and places at front
- Insertion Sort O(n²) - Builds sorted portion one element at a time
- Merge Sort O(n log n) - Divide and conquer, merges sorted halves
- Quick Sort O(n log n) - Partitions around a pivot element
- Heap Sort O(n log n) - Uses heap data structure
Code Editor
Click the </> button to open the code editor. You can modify algorithms and click "Run" to test your changes.
Available helpers: compare(i, j), swap(i, j), markSorted(indices), setPivot(i)
Keyboard Shortcuts
- Space - Start/Stop sorting
- R - Shuffle array
- E - Toggle code editor
- H - Toggle results history
- 1-6 - Select algorithm
- Escape - Stop animation