Skip to content

Commit 03f9940

Browse files
kgashokpoyea
authored andcommitted
Refactored to one pop() (#917)
1 parent 4fb4cb4 commit 03f9940

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: sorts/merge_sort.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def merge(left, right):
3737
'''
3838
result = []
3939
while left and right:
40-
result.append(left.pop(0) if left[0] <= right[0] else right.pop(0))
40+
result.append((left if left[0] <= right[0] else right).pop(0))
4141
return result + left + right
4242
if len(collection) <= 1:
4343
return collection
@@ -53,4 +53,4 @@ def merge(left, right):
5353

5454
user_input = raw_input('Enter numbers separated by a comma:\n').strip()
5555
unsorted = [int(item) for item in user_input.split(',')]
56-
print(*merge_sort(unsorted), sep=',')
56+
print(*merge_sort(unsorted), sep=',')

0 commit comments

Comments
 (0)