1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3"""
4Created on Sun Mar 10 17:13:56 2019
5
6@note: Insertion sort algorithm
7@source: http://interactivepython.org/courselib/static/pythonds/SortSearch/TheInsertionSort.html
8
9"""
10
11def insertionSort(alist):
12 for index in range(1,len(alist)):
13
14 currentvalue = alist[index]
15 position = index
16
17 while position>0 and alist[position-1]>currentvalue:
18 alist[position]=alist[position-1]
19 position = position-1
20
21 alist[position]=currentvalue
22