Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def insertionSort(myList):
- for i in range(0, len(myList)):
- j = i
- while j > 0 and myList[j-1] > myList[j]:
- myList[j] , myList[j-1] = myList[j-1], myList[j]
- j -= 1
- return myList
- # main function
- print("Enter the array to be sorted : ")
- myList1 = list(map(int, input().strip().split(",")))
- myList1 = insertionSort(myList1)
- print("The List after applying Bubble Sort is : ")
- print(myList1)
Add Comment
Please, Sign In to add comment