Skip to content

Instantly share code, notes, and snippets.

@PttCodingMan
Last active May 20, 2022 09:37
Show Gist options
  • Save PttCodingMan/0d972f94067c22c214537e414f5baa6a to your computer and use it in GitHub Desktop.
Save PttCodingMan/0d972f94067c22c214537e414f5baa6a to your computer and use it in GitHub Desktop.
def quick_sort(data: list[int]) -> list[int]:
if (length := len(data)) <= 1:
return data
pivot = data.pop(length // 2)
smaller_list = [i for i in data if i < pivot]
bigger_list = [i for i in data if i >= pivot]
return quick_sort(smaller_list) + [pivot] + quick_sort(bigger_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment