Back to demos
Demo - Bubble Sort
Watch the algorithm swap
A synthetic trace through bubble sort on [5, 2, 8, 1, 9, 3]. Step through frames to watch elements swap.
2
5
8
1
9
3
step 1/16 - Swap arr[0] -> arr[1]
1/16
Swap arr[0] -> arr[1]
if (arr[0] > arr[1]) swap(arr, 0, 1)
// 5 > 2 -> swap