Skip to content

Instantly share code, notes, and snippets.

@sh4869
Created September 17, 2014 03:02
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 sh4869/d3d44ea43c1d0dabfa9e to your computer and use it in GitHub Desktop.
Save sh4869/d3d44ea43c1d0dabfa9e to your computer and use it in GitHub Desktop.
def quicksort(nums,size):
i = 1
las = 1
if size < 2:
return
while size > i:
if nums[0] < nums[i]:
swap = nums[las]
nums[las] = nums[i]
nums[i] = swap
las = las + 1
i = i +1
swap = nums[0]
nums[0] = nums[las-1]
nums[las-1] = swap
quicksort(nums,las)
quicksort(nums.del(1>last),size-las)
i = 0
data = [46,22,34,74,85,56,18]
lenth = 7
while i < lenth:
print data[i]
i += 1
quicksort(data,lenth)
while i < lenth:
print data[i]
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment