title: Java: Sorting a 2D Array by Columns without Arrays.sort()
body: <p>I'm trying to set up a method that will sort a two dimensional array of doubles by column. Based on the provided specifications, this method is also not supposed to take ragged arrays with rows of unequal lengths. I'm testing this using the double[][] mdarray = {{3.0, 4.0, 1.0, 8.0}, {13.0, 2.0, 12.0, 9.0}</p>
  
  <p>Using a print method, this should be displayed as</p>
  
  <p>3.0, 2.0, 1.0, 8.0,</p>
  
  <p>13.0, 4.0, 12.0, 9.0,</p>
  
  <p>When using a separate print method to output the result, the array appears to be unchanged. I think my problem is figuring out how to check every row for a given column before moving onto the next, but I'm not sure how to do that easily without the Arrays.sort() method, which is not allowed for this exercise.</p>
  
  <pre><code>public void sort(boolean byColumn)
  {
      if(isRagged() == true)
      {
          System.out.println("Ragged arrays cannot be sorted by column.");
      }
      else
      {
          for(int i = 0; i &lt; mdarray.length; i++)
          {
              for(int j = i + 1; j &lt; mdarray.length - 1; j ++)
              {
                  for(int k = 0; k &lt; mdarray[i].length; k++)
                  {
                      if(mdarray[i][k] &gt; mdarray[j][k])
                      {
                          double temp = mdarray[i][k];
                          mdarray[i][k] = mdarray[j][k];
                          mdarray[i][k] = temp;
                      }
                  }
              }
          }
      }
  }
  </code></pre>