Watch the invariant
Green values satisfy the algorithm’s current guarantee: a sorted suffix, sorted prefix, fixed pivot, completed merge, or finished output position.
Compare how ten fundamental sorting methods inspect, move, divide, distribute, and finally order the same data. Every step explains the active operation and updates the cost counters.
Select a method, enter up to 12 non-negative integers, and use the controls to study every meaningful operation.
Enter between 2 and 12 integers from 0 to 99, separated by spaces or commas.
The table states the standard textbook bounds. Actual performance also depends on input order, implementation details, cache behavior, pivot choice, and gap sequence.
| Algorithm | Family | Best | Average | Worst | Extra space | Stable? | In place? |
|---|---|---|---|---|---|---|---|
| Bubble Sort | comparison | O(n) | O(n²) | O(n²) | O(1) | Yes | Yes |
| Selection Sort | comparison | O(n²) | O(n²) | O(n²) | O(1) | No | Yes |
| Insertion Sort | comparison | O(n) | O(n²) | O(n²) | O(1) | Yes | Yes |
| Merge Sort | comparison | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes | No |
| Quick Sort | comparison | O(n log n) | O(n log n) | O(n²) | O(log n) average stack | No | Yes |
| Heap Sort | comparison | O(n log n) | O(n log n) | O(n log n) | O(1) | No | Yes |
| Shell Sort | comparison | Depends on gaps | Depends on gaps | O(n²) | O(1) | No | Yes |
| Counting Sort | distribution | O(n + k) | O(n + k) | O(n + k) | O(n + k) | Yes | No |
| Radix Sort | distribution | O(d(n + b)) | O(d(n + b)) | O(d(n + b)) | O(n + b) | Yes | No |
| Bucket Sort | distribution | O(n + k) | O(n + k) | O(n²) | O(n + k) | Can be | No |
Green values satisfy the algorithm’s current guarantee: a sorted suffix, sorted prefix, fixed pivot, completed merge, or finished output position.
Merge uses temporary storage; Shell exposes its gap; Heap shows the active heap; Counting, Radix, and Bucket Sort reveal their distribution structures.
Run the same array through different methods. The counters make comparisons, swaps, and writes concrete without pretending that every operation has identical machine cost.