Repeatedly compares neighbors and swaps them if they're out of order. Click Worst to feed it a reverse-sorted array and watch the comparison count climb.
›Click Run to begin.
Splits the array in half, sorts each half, merges them back in order. No swaps — writes. Same effort no matter the input, which is exactly the point.
›Click Run to begin.
Picks a pivot, partitions smaller left / larger right, recurses. Click Worst to see already-sorted data quietly drag it back to O(n²). Watch for the violet PIVOT marker — that's the one choice that decides everything else.
›Click Run to begin.
The trade-offs, side by side
| Algorithm | Time (avg) | Space | Stable? | Where it earns its place |
|---|---|---|---|---|
| Bubble Sort | O(n²) | O(1) | Yes | Teaching, tiny or nearly-sorted arrays |
| Merge Sort | O(n log n) | O(n) | Yes | Guaranteed performance, external/linked-list sorts |
| Quick Sort | O(n log n) | O(log n) | No | General-purpose default, in-memory arrays |
None of these are "the best" sort in the abstract — that's the same trap as picking a database index without checking the actual workload. Bubble sort is genuinely fine for sixteen elements. Merge sort's O(n) space cost is a real trade for its guaranteed O(n log n) ceiling. Quick sort's average-case speed comes with a worst case you should actually know about, not just accept on faith. Run the three panels above again with that in mind.