# Insertion sort Python code you can run

> Run insertion sort Python code and watch its sorted prefix grow beside bubble and selection sort.

Source: https://fullbytedeveloper.com/blog/insertion-sort-python
Keyword: INSERT
Published here: 2026-11-23

I built this insertion sort Python level so you can run it. ALGO ARCADE runs each level as one Python file [1].

## Run insertion sort Python code

```bash
python3 insertion_sort.py
```

You should see the default row become ordered.

## Try an insertion sort Python example

```bash
python3 insertion_sort.py 1 2 3 4 5
```

You should see each value stay in the sorted prefix.

## Race insertion sort with the other sorting levels

The arcade races every current sorting level on the same shuffled 10,000-number row. It runs each plain sorting function three times and prints the median time [1].

```bash
python3 arcade.py --race 10000
```

You should see Bubble sort, Selection sort, Insertion sort, Merge sort, Quick sort, and Heap sort with a time and extra-memory line.

## Inspect the insertion sort algorithm

Insertion sort moves the next value left until its neighbor is no longer larger [2]. [Bubble sort uses neighbor swaps](/blog/bubble-sort-python). [Selection sort chooses one smallest value per round](/blog/selection-sort-python). Find the rest in [Dev explainers](https://fullbytedeveloper.com/blog/topic/dev-explainers).

Send this to the friend who needs a runnable model of insertion sort.

## Sources

1. [ALGO ARCADE README](https://github.com/kamilikamil/algo-arcade/blob/main/README.md)
2. [ALGO ARCADE insertion sort source](https://github.com/kamilikamil/algo-arcade/blob/main/insertion_sort.py)
