title: How do I sort a 2D array?
body: <p>I want to sort an 2D-array in zig-zag order using only the first number. For example:</p>
  
  <pre><code>int[][] a = {{2,5,4}{5,3,5}{56,5,54}{353,35}}
  sort(a)
  System.out.println(a)
  </code></pre>
  
  <p>What I want it to print is <code>((2,5,4),(56,5,54),(5,3,5),(353,35))</code>. Is there any way to do this with a time complexity of O(n)?</p>
  
  <p>This is not a duplicate because I want it in O(n).</p>