Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice
- def quick_sort(a_list):
- if len(a_list) <= 1:
- return a_list
- pivot = choice(range(len(a_list)))
- return quick_sort([i for i in a_list[:pivot] + a_list[pivot+1:]
- if i < a_list[pivot]]) + [a_list[pivot]] + \
- quick_sort([i for i in a_list[:pivot] + a_list[pivot+1:]
- if i >= a_list[pivot]])
Add Comment
Please, Sign In to add comment