#! /usr/bin/env python2 # -*- coding: utf-8 -*- lst = [20, 46, -51, 35, -72, 51, 90, -92, -12, -1] def insertion_sort(lst): for i in range(1, len(lst)): value = lst[i] j = i while j > 0 and lst[j - 1] > value: lst[j] = lst[j - 1] j = j - 1 lst[j] = value # print(lst) print 'before: ', lst insertion_sort(lst) print 'after: ', lst