title: Merging a 2D array with sorted rows into a big 1D array
body: <p>Given a 2d array which each row is sorted from left to right, from the smallest to the biggest, I want to sort the entire array into a 1D array from the smallest to the biggest.</p>
  
  <p>the number of rows is N and the number of columns is M.
  the complexity I need for it is M<em>N</em>log(N)</p>
  
  <p>What I had in mind to do, is do some kind of a merge sort on the 2d array and each time send 2 rows for the function and there is the point I got stuck.</p>
  
  <p>the signature I'm given for the function is </p>
  
  <pre><code>void sort_rect(int a[N][M], int b[])
  </code></pre>
  
  <p>I'm promised the the 1d array of b has enough space for all the element of the 2d array.#C!!!</p>