Skip to content

Instantly share code, notes, and snippets.

@pdparker
Created February 28, 2014 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdparker/9263270 to your computer and use it in GitHub Desktop.
Save pdparker/9263270 to your computer and use it in GitHub Desktop.
shell sort
def shellSort(x):
h = len(x)//2
i = h
while h > 0:
while i < len(x):
for j in range(i,0,-1):
if x[j] < x[j-h]:
x[j],x[j-h] = x[j-h],x[j]
else:
break
i = i+1
print(x)
h = h//2
i=h
return(x)
y = [i for i in 'sortexample']
shellSort(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment