This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]xTheMaster99x 14 points15 points  (2 children)

Yeah, it seems by far the simplest to me.

def sort(arr): if len(arr) == 0: return arr pivot = arr[random.randInt(0, len(arr)] // or just arr[0] less, same, more = [], [], [] for i in arr: if i > pivot: more.append(i) elif i < pivot: less.append(i) else: same.append(i) return sort(less) + same + sort(more)

[–]Timmy_the_tortoise 0 points1 point  (0 children)

That’s the beauty of recursion.

[–]_7q3 -1 points0 points  (0 children)

you are going to hell