Guest User

Untitled

a guest
Apr 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def quicksort(l):
  2. if(len(l)<=1):
  3. return l
  4. less,greater = ([],[])
  5. pivot = len(l)/2
  6. for n in l:
  7. if l[n] <= l[pivot] and not l.__contains__(n):
  8. less.append(l[n])
  9. elif not l.__contains__(n):
  10. greater.append(l[n])
  11. less.append(l[pivot])
  12. return quicksort(less) + quicksort(greater)
  13.  
  14. if __name__ == '__main__':
  15. listToBeSorted = [1,6,1,3,7,3,4,7,9,2,3,6,12,13]
  16. print quicksort(listToBeSorted)
Add Comment
Please, Sign In to add comment