implement merge sort via external atoms for splitting and merging