"""
by John von Neumann
"""
def MergeSort(lists):
if len(lists)<=1:
return lists
num=int(len(lists)/2)
left=MergeSort(lists[:num])
right=MergeSort(lists[num:])
return Merge(left,right)
def Merge(left,right):
l,r=0,0;
result=[]
while l<len(left) and r<len(right):
if left[l]<right[r]:
result.append(left[l])
l+=1
else:
result.append(right(r))
r+=1
result+=left[l:]
result+=right[r:]
return result
if __name__=="__main__":
L=[random.randint(0,100) for _ in range(10)]
print (type(L))
print (L)
starttime=datetime.datetime.now()
print (quicksort(L,0,len(L)-1))
endtime=datetime.datetime.now()
print ((endtime-starttime))
starttime = datetime.datetime.now()
print (MergeSort(L))
endtime = datetime.datetime.now()
print((endtime - starttime))
Traceback (most recent call last):
File "/home/stephen/PycharmProjects/quicksort/quicksort.py", line 85, in <module>
print (MergeSort(L))
File "/home/stephen/PycharmProjects/quicksort/quicksort.py", line 41, in MergeSort
return Merge(left,right)
File "/home/stephen/PycharmProjects/quicksort/quicksort.py", line 50, in Merge
result.append(right(r))
TypeError: "list" object is not callable