O(patience)

Visualize. Compare. Understand.

Enter

a sorting playground · made by Abhirai

made by Abhirai

Seehowsortingactually works.

Step through the inner loop of five classic algorithms. Watch every compare, swap and write — with live complexity and stats.

Algorithm Visualizer

21
0
25
1
90
2
21
3
39
4
46
5
59
6
59
7
13
8
95
9
90
10
29
11
43
12
51
13
20
14
51
15
43
16
8
17
71
18
95
19
idlePress Play to begin
step 00 total
Legend:unsortedcomparingpivotsorted
⚠ Duplicate valuesEqual-height bars can make compares/swaps look like no-ops — affects stable-vs-unstable demos.

⚙️ Parameters

▶︎ Playback & tools

🔢 Custom array— comma or space separated, 1–100, up to 100 numbers

📖 Step history

showing last 0 of 0

No steps yet — press Play.

Comparisons

0

Swaps

0

Array writes

0

Quick Sort

Picks a pivot, partitions elements into less-than / greater-than groups, then recurses. Fast in practice and cache-friendly.

Stable: NoSpace O(log n)

Real-world use

  • General-purpose in-memory sort
  • Language standard libraries (with introsort fallback)

Complexity

Best

O(n log n)

Average

O(n log n)

Worst

O(n²)

Space

O(log n)

Keyboard

Space — play/pause   ·   ←/→ — step   ·   R — reset

Pseudocode — Quick Sort

idle
1quickSort(a, low, high):
2 if low >= high: return
3 p = partition(a, low, high)
4 quickSort(a, low, p-1)
5 quickSort(a, p+1, high)
6
7partition(a, low, high):
8 pivot = a[high]; i = low
9 for j from low to high-1:
10 if a[j] < pivot: swap(a[i], a[j]); i++
11 swap(a[i], a[high])
12 return i

🏁 Race all algorithms

Same input, every algorithm — watch them sort side by side.

Pick a size and pattern, then hit Load race.