MERGE(A,p,q,r)
N1←q-p+1
N2←r-q
Creat arrays L[1……n1+1] and R[1….n2+1]
For i←1 to n1
Do l[i]←A[p+i-1]
For j←1 to n2
Do R[j]←A[q+j]
L[n1+1]←∞
R[n2+1]←∞
i←1
j←1
for k←p to r
do if Li]<=R[j]
then A[k]←l[j]
i←i+1
else A[k]←R[j]
j←j+1
NERGE_SORT(A,p,r)
If p<r
Then q←[(p+r)/2]
MERGE_SORT(A,p,q)
MERGE_SORT(A,p+1,q)
MERGE_SORT(A,p,q,r)