Insertion Sort
Insertion Sort
EasySorting50% accepted
Implement Insertion Sort: build the sorted array one element at a time by inserting each new element into its correct position among the already-sorted elements. Think of it like sorting a hand of playing cards — you pick up one card at a time and slide it into position.
Approach
Given N integers, sort them using insertion sort and print the sorted array.
Input
5
64 34 25 12 22
Output
12 22 25 34 64
More Sorting problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards