You are viewing a single comment's thread. Return to all comments →
@jonmcclung Thanks for your code sharing. I learned alot. I tried to improve your code as following:
def quick_sort(ar): p, *a = ar first, last = [], [] for i in a: if i < p: first.append(i) else: last.append(i) if len(first) > 1: first = quick_sort(first) if len(last) > 1: last = quick_sort(last) kth_sorted = first + [p] + last print(*kth_sorted) return kth_sorted def main(): input() arr = list(map(int, input().strip().split())) quick_sort(arr) main()
Seems like cookies are disabled on this browser, please enable them to open this website
Quicksort 2 - Sorting
You are viewing a single comment's thread. Return to all comments →
@jonmcclung Thanks for your code sharing. I learned alot. I tried to improve your code as following: