Algomination
Sorting
Searching
Data Structures
About
Contact
All sorting algorithms
Insertion Sort
Time O(n²)
Space O(1)
Builds a sorted prefix by inserting each new element into its correct spot.
Visualize
Random
6
2
9
1
7
3
8
Starting Insertion Sort. The first element is a sorted prefix.
Play
Step 1 / 36
0.5×
1×
2×
4×
Sorted
Key / Active
Comparing
Swapping