Insertion sort

How it works →

Up to 24 values. Try duplicates or negative numbers.

Step 0 / 27: Original array. The first element starts the sorted prefix.

Array: [5, 2, 4, 2, 1]

Comparisons: 0 · Writes: 0

Green: sorted prefix. Purple: held value. Highlighted bars: current operation. Positions start at zero.