Update merge_sort_fastest.py

This commit is contained in:
Harshil 2018-05-21 10:28:37 +02:00 committed by GitHub
parent 7f4b240d1a
commit 71fd719ab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,15 +7,13 @@ Worst Case Scenario : O(n)
def merge_sort(LIST):
start = []
end = []
while LIST:
while len(LIST) > 1:
a = min(LIST)
b = max(LIST)
start.append(a)
end.append(b)
try:
LIST.remove(a)
LIST.remove(b)
except ValueError:
continue
if LIST: start.append(LIST[0])
end.reverse()
return (start + end)