Files
Python/sorts/merge_sort_fastest.py
Harshil 7f4b240d1a Update merge_sort_fastest.py
I have modified the code a little to make it work as expected!
2018-05-21 10:21:33 +02:00

22 lines
496 B
Python

'''
Python implementation of merge sort algorithm.
Takes an average of 0.6 microseconds to sort a list of length 1000 items.
Best Case Scenario : O(n)
Worst Case Scenario : O(n)
'''
def merge_sort(LIST):
start = []
end = []
while LIST:
a = min(LIST)
b = max(LIST)
start.append(a)
end.append(b)
try:
LIST.remove(a)
LIST.remove(b)
except ValueError:
continue
end.reverse()
return (start + end)