Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def quicksort(x):
- if not x:
- return []
- pivot = x[0]
- smaller = quicksort([a for a in x[1:] if a <= pivot])
- bigger = quicksort([a for a in x[1:] if a > pivot])
- return(smaller + [pivot] + bigger)
- x = [10, 2, 5, 3, 1, 6, 7, 4, 2, 3, 4, 8, 9]
- print(quicksort(x))
Add Comment
Please, Sign In to add comment