From 78402c5f42bc3e3e075b9e81ad72c51c1dea76b9 Mon Sep 17 00:00:00 2001 From: miczal Date: Thu, 11 Aug 2016 20:02:06 +0200 Subject: [PATCH] [Quicksort]Added shuffling of input --- sorts/quick_sort.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sorts/quick_sort.py b/sorts/quick_sort.py index fa6597041..4e6516cd8 100644 --- a/sorts/quick_sort.py +++ b/sorts/quick_sort.py @@ -10,6 +10,12 @@ For manual testing run: python quick_sort.py """ from __future__ import print_function +from random import shuffle + + +def sort(collection): + shuffle(collection) + return quick_sort(collection) def quick_sort(collection): @@ -58,4 +64,4 @@ if __name__ == '__main__': user_input = input_function('Enter numbers separated by coma:\n') unsorted = [int(item) for item in user_input.split(',')] - print(quick_sort(unsorted)) + print(sort(unsorted))