Guest User

Untitled

a guest
May 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. def quicksort(x):
  2. if not x:
  3. return []
  4.  
  5. pivot = x[0]
  6. smaller = quicksort([a for a in x[1:] if a <= pivot])
  7. bigger = quicksort([a for a in x[1:] if a > pivot])
  8.  
  9. return(smaller + [pivot] + bigger)
  10.  
  11.  
  12. x = [10, 2, 5, 3, 1, 6, 7, 4, 2, 3, 4, 8, 9]
  13. print(quicksort(x))
Add Comment
Please, Sign In to add comment