Sorting Algorithm Visualizer
Watch quicksort, merge sort and more sort your numbers, and race two side by side.
Algorithms
Pathfinding Visualizer
Sorting Algorithm Visualizer
Graph Algorithms Visualizer
Questions
Which sorting algorithm is fastest?
For general data, quicksort is usually fastest in practice, and merge sort and heapsort guarantee O(n log n). Insertion sort wins on small or nearly sorted lists. Try "Nearly sorted" and race insertion against quicksort.
What does stable mean?
A stable sort keeps equal items in the order they started in. It matters when you sort by one field after another, like by name and then by date.
What do comparisons and writes count?
Comparisons is how many times two items were compared. Writes is how many times a value was put into the list. They show the work each algorithm did on exactly the same input.
Why is quicksort not O(n²) on sorted input here?
This quicksort picks the middle item as its pivot. Picking the first or last item makes sorted input the worst case, which is a common mistake.
Can I sort my own numbers?
Yes. Type up to 300 numbers, separated by commas, spaces or new lines. Decimals and negative numbers are fine.
Related tools
- Pathfinding VisualizerDraw walls and watch A*, Dijkstra, BFS and more find a path, or race two.
- Graph Algorithms VisualizerType an edge list and see shortest paths, BFS, DFS, topological order or a spanning tree.
- Base ConverterBinary, octal, decimal and hex, all at once.
- IEEE 754 Float InspectorThe bits and exact value of any float or double, such as 0.1 + 0.2.