import copy as cp
import sys
def marge(inputay,p,q,r):
ay = cp.copy(inputay[p:q+1])
ay.append(sys.maxsize)
by = cp.copy(inputay[q+1:r+1])
by.append(sys.maxsize)
ai = 0
bi = 0
for i in range(p,r+1):
if(ay[ai] > by[bi]):
inputay[i] = by[bi]
bi = bi+1
else:
inputay[i] = ay[ai]
ai = ai+1
return
def margeSort(inputay,p,r):
if(r == p):
return
q = int((r-p)/2 +p)
margeSort(inputay,p,q)
margeSort(inputay,q+1,r)
marge(inputay,p,q,r)
ay = [5,4,3,2,1,0]
#输入点index。len-1才是最后一个数的index
margeSort(ay,0,len(ay)-1)