Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Insertion Sort Function
- #R@1313I
- def InsertionSort(arr):
- for i in range( 1,len(arr)):
- key = arr[i]
- j = i-1
- #Iteration / Change to < for increasing sorted order
- while j >= 0 and arr[j] > key:
- arr[j+1] = arr[j] #
- j=j-1
- arr[j+1] = key
- #Checking Function
- arr = [3,2,5,9,1,0]
- InsertionSort(arr)
- print("Sorted Number is: ")
- for i in range(len(arr)):
- print(arr[i])
Add Comment
Please, Sign In to add comment