MERGE(A,p,q,r)
n1=q-p+1
n2=r-q
let L[1...n1]andR[1...n2] be new arrays
for i = 1 to n1
L[i]=A[p+i-1]
for j = 1 to n2
R[j]=A[q+j]
i=1
j=1
for k = p to r
if(i<=n1 && (j>n2 || L[i]<=R[j]))
A[k]=L[i]
i=i+1
else
A[k]=R[j]
j=j+1
仅供参考,如有错误欢迎指正,感激不尽!