Implement the classic insertion sort algorithm with in-place mutation.
Constraints
Example
>>> arr = [5, 2, 9, 1] >>> result = insertion_sort(arr) >>> result is arr True >>> result [1, 2, 5, 9] >>> lst = [] >>> insertion_sort(lst) [] >>> lst = [3] >>> insertion_sort(lst) [3]
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints