coding-quiz-3
---
id: coding-quiz-3
title: Coding Quiz - Implement Insertion Sort
description: Write a function to sort a list of numbers in ascending order using the insertion sort algorithm.
tags:
- Coding Quiz
- Insertion Sort
- Python
sidebar_position: 12
isPublic: false
---
# Coding Quiz - Implement Insertion Sort
Based on what you've learned so far, implement the `insertion sort` algorithm yourself.
<br />
```python title="Write your code here"
def solution(numbers):
# Write your code here
return
Constraints
-
numbers
is a list containing numbers. -
The
length of the list
must be at least 1.
Examples
-
Input:
[6, 5, 3, 1, 8, 7, 2, 4]
-
Output:
[1, 2, 3, 4, 5, 6, 7, 8]
-
Input:
[3, 1, 4, 1, 5]
-
Output:
[1, 1, 3, 4, 5]
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.