mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Merge pull request #16 from miczal/master
[Quicksort]Added shuffling of input
This commit is contained in:
commit
e3c24fe59a
@ -10,6 +10,12 @@ For manual testing run:
|
|||||||
python quick_sort.py
|
python quick_sort.py
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
from random import shuffle
|
||||||
|
|
||||||
|
|
||||||
|
def sort(collection):
|
||||||
|
shuffle(collection)
|
||||||
|
return quick_sort(collection)
|
||||||
|
|
||||||
|
|
||||||
def quick_sort(collection):
|
def quick_sort(collection):
|
||||||
@ -58,4 +64,4 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
user_input = input_function('Enter numbers separated by coma:\n')
|
user_input = input_function('Enter numbers separated by coma:\n')
|
||||||
unsorted = [int(item) for item in user_input.split(',')]
|
unsorted = [int(item) for item in user_input.split(',')]
|
||||||
print(quick_sort(unsorted))
|
print(sort(unsorted))
|
||||||
|
Loading…
Reference in New Issue
Block a user