Skip to content

Instantly share code, notes, and snippets.

@krypton-byte
Created February 14, 2022 11:28
Show Gist options
  • Select an option

  • Save krypton-byte/89fec4d51c604f68a6ae7c7564109955 to your computer and use it in GitHub Desktop.

Select an option

Save krypton-byte/89fec4d51c604f68a6ae7c7564109955 to your computer and use it in GitHub Desktop.
Quick Sort Algorithm
from typing import Generator
def quick_sort(sequence: list) -> Generator:
if sequence.__len__() <= 1:
yield from sequence
else:
low = []
high = []
pivot = sequence.pop()
for i in sequence:
[low, high][i > pivot].append(i)
yield from quick_sort(low)
yield pivot
yield from quick_sort(high)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment