mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-31 06:33:44 +00:00
Added some other spaces
This commit is contained in:
parent
8d06eb2c63
commit
7ae9759220
|
@ -29,13 +29,13 @@ def quick_sort(ARRAY):
|
||||||
>>> quick_sort([-2, -5, -45])
|
>>> quick_sort([-2, -5, -45])
|
||||||
[-45, -5, -2]
|
[-45, -5, -2]
|
||||||
"""
|
"""
|
||||||
ARRAY_LENGTH=len(ARRAY)
|
ARRAY_LENGTH = len(ARRAY)
|
||||||
if( ARRAY_LENGTH <= 1):
|
if( ARRAY_LENGTH <= 1):
|
||||||
return ARRAY
|
return ARRAY
|
||||||
else:
|
else:
|
||||||
PIVOT = ARRAY[0]
|
PIVOT = ARRAY[0]
|
||||||
GREATER = [element for element in ARRAY[1:] if element > PIVOT]
|
GREATER = [ element for element in ARRAY[1:] if element > PIVOT ]
|
||||||
LESSER = [element for element in ARRAY[1:] if element <= PIVOT]
|
LESSER = [ element for element in ARRAY[1:] if element <= PIVOT ]
|
||||||
return quick_sort(LESSER) + [PIVOT] + quick_sort(GREATER)
|
return quick_sort(LESSER) + [PIVOT] + quick_sort(GREATER)
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,5 +50,5 @@ if __name__ == '__main__':
|
||||||
input_function = input
|
input_function = input
|
||||||
|
|
||||||
user_input = input_function('Enter numbers separated by a comma:\n')
|
user_input = input_function('Enter numbers separated by a comma:\n')
|
||||||
unsorted = [int(item) for item in user_input.split(',')]
|
unsorted = [ int(item) for item in user_input.split(',') ]
|
||||||
print(quick_sort(unsorted))
|
print( quick_sort(unsorted) )
|
||||||
|
|
Loading…
Reference in New Issue
Block a user