Skip to content

Instantly share code, notes, and snippets.

@imedadel
Created October 31, 2019 22:28
Show Gist options
  • Select an option

  • Save imedadel/689b21de783f85623e42b469efd62b25 to your computer and use it in GitHub Desktop.

Select an option

Save imedadel/689b21de783f85623e42b469efd62b25 to your computer and use it in GitHub Desktop.
def quicksort(arr):
if len(arr) < 2:
return arr
pivot = arr[0]
less = [i for i in arr[1:] if i <= pivot]
greater = [i for i in arr[1:] if i > pivot]
return quicksort(less) + [pivot] + quicksort(greater)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment