Skip to content

Instantly share code, notes, and snippets.

@anonymousmaharaj
Created May 28, 2021 10:11
Show Gist options
  • Save anonymousmaharaj/d1a54dcc8373406ba8a212303ee474dc to your computer and use it in GitHub Desktop.
Save anonymousmaharaj/d1a54dcc8373406ba8a212303ee474dc to your computer and use it in GitHub Desktop.
qsort
def qsort(arr):
if len(arr) < 2:
return arr
else:
pivot = arr[0]
less = [i for i in arr if i < pivot]
mid = [i for i in arr if i == pivot]
great = [i for i in arr if i > pivot]
return qsort(less) + mid + qsort(great)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment