title: Sort a 2D array in C++ using built in functions(or any other method)?
body: <p>I have a 2D array like below. ( <code>array[5][2]</code> )</p>
  
  <pre><code>20  11    
  10  20
  39  14
  29  15
  22  23
  </code></pre>
  
  <p>after sorting it should be like below.</p>
  
  <pre><code>10  20
  20  11
  22  23
  29  15
  39  14
  </code></pre>
  
  <p>that means the array should be sorted comparing the first column values only.</p>
  
  <p>In Java there is a built in function capability to do that. like below.</p>
  
  <pre><code>Arrays.sort(a, new Comparator&lt;Long[]&gt;() {
  
              @Override
              public int compare(Long[] o1, Long[] o2) {
  
                  Long t1 = o1[1];
                  Long p1 = o1[0];
                  Long t2 = o2[1];
                  Long p2 = o2[0];
  
                  if (t1 == t2) {
                      return (p1 &gt; p2 ? 1 : (p1 == p2 ? 0 : -1));
                  } else {
                      return (t1 &lt; t2 ? -1 : 1);
                  }
  
              }
          });
  </code></pre>
  
  <p>So is there any C++ built in function capability to do these kind of stuff or how can i do this in C++ (the fastest implementation) ?</p>
  
  <p>Thanks in advance :) </p>