small change!

This commit is contained in:
Harshil 2018-05-28 23:34:21 +02:00 committed by GitHub
parent ca7eb46756
commit 31f968f589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,13 +1,11 @@
from __future__ import print_function from __future__ import print_function
def quick_sort_3partition(sorting, left, right): def quick_sort_3partition(sorting, left, right):
if right <= left: if right <= left:
return return
a = left a = i = left
b = right b = right
pivot = sorting[left] pivot = sorting[left]
i = left
while i <= b: while i <= b:
if sorting[i] < pivot: if sorting[i] < pivot:
sorting[a], sorting[i] = sorting[i], sorting[a] sorting[a], sorting[i] = sorting[i], sorting[a]
@ -30,4 +28,4 @@ if __name__ == '__main__':
user_input = raw_input('Enter numbers separated by a comma:\n').strip() user_input = raw_input('Enter numbers separated by a comma:\n').strip()
unsorted = [ int(item) for item in user_input.split(',') ] unsorted = [ int(item) for item in user_input.split(',') ]
quick_sort_3partition(unsorted,0,len(unsorted)-1) quick_sort_3partition(unsorted,0,len(unsorted)-1)
print(unsorted) print(unsorted)