Browse Source

Merge pull request #4 from sunny3p/master

Merge Sort without Slicing
pull/10/head
Jeffery Russell 6 years ago
committed by GitHub
parent
commit
590d060c3b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      sorting/insertionSort.py

+ 18
- 0
sorting/insertionSort.py View File

@ -0,0 +1,18 @@
# coding: utf-8
# In[55]:
alist = [54,26,93,17,77,31,44,55,20]
def insertionSort(alist):
for index in range(1,len(alist)):
currentvalue = alist[index]
position = index
while position>0 and alist[position-1]>currentvalue:
alist[position]=alist[position-1]
position = position-1
alist[position]=currentvalue
return alist
print(insertionSort(alist))

Loading…
Cancel
Save