Skip to content

Commit 71fd719

Browse files
authored
Update merge_sort_fastest.py
1 parent 7f4b240 commit 71fd719

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sorts/merge_sort_fastest.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
def merge_sort(LIST):
88
start = []
99
end = []
10-
while LIST:
10+
while len(LIST) > 1:
1111
a = min(LIST)
1212
b = max(LIST)
1313
start.append(a)
1414
end.append(b)
15-
try:
16-
LIST.remove(a)
17-
LIST.remove(b)
18-
except ValueError:
19-
continue
15+
LIST.remove(a)
16+
LIST.remove(b)
17+
if LIST: start.append(LIST[0])
2018
end.reverse()
2119
return (start + end)

0 commit comments

Comments
 (0)