function ParallelMergeSort(L, start, end, k, id = 1):
if start< end :
m = (start + end) / 2
if id + 1 <= m:
Pid+1 do ParallelMergeSort(L, start, m, k, id + 1)
Pid+1 do ParallelMergeSort(L, m + 1, end, k, id + 2)
Set Barrier
Merge(L, start, m, end)
else:
MergeSort(L, start, m)
MergeSort(L, m + 1, end)
Merge(L, start, m, end)
end if
end if
end function