human
Insertion Sort | Function to do insertion sort.
Move elements of arr [ 0. . i - 1 ] , that are greater than key , to one position ahead of their current position.
Driver code to test above"
How can the above be solved in Python?
assistant
#Here is code to insertion Sort and the other steps required.
 def insertionSort ( arr ) :
	for i in range ( 1 , len ( arr ) ) :
		key = arr [ i ]
		j = i - 1
		while j >= 0 and key < arr [ j ] :
			arr [ j + 1 ] = arr [ j ]
			j -= 1
		arr [ j + 1 ] = key
arr = [ 12 , 11 , 13 , 5 , 6 ]
insertionSort ( arr )
for i in range ( len ( arr ) ) :
	print ( " % ▁ d " % arr [ i ] )