title: Sorting 2D Array C++
body: <p>Is it possible to sort a 2D Array using qsort or std::sort in C++ such that the elements are in increasing order when read from left to right in each row or from top to bottom in each column?</p>
  
  <p>For example,</p>
  
  <pre><code>13, 14, 15, 16
  1, 4, 3, 2
  7, 5, 7, 6
  9, 10, 11, 12
  </code></pre>
  
  <p>Becomes:</p>
  
  <pre><code>{ 1, 2, 3, 4 }
  { 5, 6, 7, 8 }
  { 9, 10, 11, 12 }
  { 13, 14, 15, 16 } 
  </code></pre>
  
  <p>I know you can do it by creating two comparison functions and then first sorting each row then comparing the first elements of each row to establish the columns, but is there a way to do it in one function itself?</p>