Skip to content

Commit 7f4b240

Browse files
authored
Update merge_sort_fastest.py
I have modified the code a little to make it work as expected!
1 parent 237df47 commit 7f4b240

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sorts/merge_sort_fastest.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
def merge_sort(LIST):
88
start = []
99
end = []
10-
a = LIST[0]
11-
b = LIST[-1]
12-
while (LIST.index(a) == LIST.index(b) and len(LIST) <=2):
10+
while LIST:
1311
a = min(LIST)
1412
b = max(LIST)
1513
start.append(a)
1614
end.append(b)
17-
LIST.remove(a)
18-
LIST.remove(b)
15+
try:
16+
LIST.remove(a)
17+
LIST.remove(b)
18+
except ValueError:
19+
continue
1920
end.reverse()
20-
return start + end
21+
return (start + end)

0 commit comments

Comments
 (0)