title: Sorting multidimensional arrays
body: <pre><code>int [][] div = {
                   {1, 1, 2},
                   {2, 1, 2},
                   {1, 2, 2},
                   {3, 1, 2},
                   {1, 2, 3},
                   {2, 1, 1},
                   {1, 1, 1}
                 };
  </code></pre>
  
  <p>I want to sort this array according to the first column.</p>
  
  <p>I've done something but I messed up. I really don't know how to swap the other columns together with the first column.</p>
  
  <pre><code>for(int x = 0; x &lt; div.length-1; x++) {
    for(int y = 0; y &lt; div.length-1;y++) {
      if(div[y][0] &gt; div[y+1][0]) {
        tmp = div[y][0];
        div[y][0] = div[y+1][0];
        div[y+1][0] = tmp;
      }                   
    }
  }
  for(int x = 0; x &lt; arr.length; x++) {   
    System.out.print(div[x][0]+" \t" + div[x][1] + "\t"+ div[x][2] +  "\n");          
  }
  </code></pre>