Skip to content

Commit 78402c5

Browse files
committed
[Quicksort]Added shuffling of input
1 parent e514065 commit 78402c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: sorts/quick_sort.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
python quick_sort.py
1111
"""
1212
from __future__ import print_function
13+
from random import shuffle
14+
15+
16+
def sort(collection):
17+
shuffle(collection)
18+
return quick_sort(collection)
1319

1420

1521
def quick_sort(collection):
@@ -58,4 +64,4 @@ def quick_sort(collection):
5864

5965
user_input = input_function('Enter numbers separated by coma:\n')
6066
unsorted = [int(item) for item in user_input.split(',')]
61-
print(quick_sort(unsorted))
67+
print(sort(unsorted))

0 commit comments

Comments
 (0)