Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def quicksort(array):
- if len(array) < 2:
- return array
- else:
- pivot = array[0]
- less = [i for i in array[1:] if i <= pivot]
- greater = [i for i in array[1:] if i > pivot]
- return quicksort(less) + list(pivot) + quicksort(greater)
- print(quicksort([10, 5, 2, 3, 12]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement