title: Algorithm to merge multiple sorted sequences into one sorted sequence in javascript
body: <p><a href="https://i.stack.imgur.com/0sQRG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0sQRG.png" alt="enter image description here"></a>I am looking for an algorithm to merge multiple sorted sequences, lets say X sorted sequences with n elements, into one sorted sequence in javascript , can you provide some examples?</p>
  
  <p>note: I do not want to use any library.
  Trying to solve <a href="https://icpc.kattis.com/problems/stacking" rel="nofollow noreferrer">https://icpc.kattis.com/problems/stacking</a></p>
  
  <p>what will be the minimal number of operations needed to merge sorted arrays, under conditions :</p>
  
  <p><strong>Split</strong>: <em>a single stack can be split into two stacks by lifting any top portion of the stack and putting it aside to form a new stack.</em></p>
  
  <p><strong>Join</strong>: <em>two stacks can be joined by putting one on top of the other. This is allowed only if the bottom plate of the top stack is no larger than the top plate of the bottom stack, that is, the joined stack has to be properly ordered.</em></p>