Last active
May 20, 2022 09:37
-
-
Save PttCodingMan/0d972f94067c22c214537e414f5baa6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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