# This program implements the insertion algorithm def insertionSort(l): n = len(l) for i in range(1,n): temp = l[i] j = i-1 while j >= 0: if temp < l[j]: l[j+1] = l[j] else: break j = j - 1 l[j+1] = temp def main(): l = input("Enter the list of numbers: ") print "Unsorted list:", l insertionSort(l) print "Sorted list:", l main()