8 lines
231 B
Python
8 lines
231 B
Python
def quicksort(arr):
|
|
if len(arr) <= 1:
|
|
return arr
|
|
pivot = arr[-1]
|
|
left = [x for x in arr[:-1] if x <= pivot]
|
|
right = [x for x in arr[:-1] if x > pivot]
|
|
return quicksort(left) + [pivot] + quicksort(right)
|