title: Sorting 2D-array as a whole
body: <p>I have a 2D array to sort as a whole using Java. </p>
  
  <p>I have looked at the various links
  <a href="https://stackoverflow.com/questions/10035447/how-to-sort-a-two-dimension-arraylist">How to sort a two-dimension ArrayList</a> using comparators.</p>
  
  <p>But it always sorts on a specific element. I want to able to sort for the whole 2d array. 
  For eg,</p>
  
  <pre><code>int[][] r = {{1,7,5},{1,3,5},{1,3,6}, {2,3,1}};
  </code></pre>
  
  <p>on sorting should give me </p>
  
  <pre><code>{1,2,3},{1,3,5},{1,3,6},{1,5,7}.
  </code></pre>
  
  <p>Thanks!</p>