Important
The end flag of the input stream should be initialized; otherwise, it can cause deadlock in the output stream. The input stream of the Merge Sort primitive should be a pre-sorted stream.
Caution
If the two input stream are both empty, the function output will be also empty.
This mergeSort
primitive has two ports for key input, two ports for payload input, one port for merged key output, one port for merged payload output, and one boolean sign for indicating ascending sort or descending sort.