title: Sorting with 2D Arrays
body: <p>I need help with sorting Random numbers into a 2D array. I have to generate 50 random numbers into a column of the array, then sort the numbers in order (ascending or descending). This is what I have so far and am so lost. Please Help.</p>
  
  <p><em><strong>UPDATED VERSION</em></strong>  </p>
  
  <pre><code>public static void main(String[] args) 
  {
      int rows = 2;
      int columns = 50;
  
      int[][] anArray = new int[rows][columns];
  
      Random rand = new Random();
  
      for (int i = 0; i &lt; anArray.length; i++) 
      {
          for (int j = 0; j &lt; anArray[0].length; j++) 
          {
              int n = rand.nextInt(100);
              anArray[i][j] = n;
          }
      }
  
      int []temp;
      for (int i=0;i&lt;anArray.length;i++)
          {  
              for (int j=0;j&lt;anArray.length-i;j++ )
              {
                  if (anArray[i][j]&gt;anArray[i][j+1])
                  {  
                      temp =anArray[j];
                      anArray[j+1]=anArray[j];
                      anArray[j+1]=temp;
                  }
              }
          } 
  
      for (int i = 0; i &lt; anArray.length; i++) 
      {
          for (int j=0;j&lt;anArray.length-i;j++ )
          { 
              System.out.println(anArray[i][j]);
          }
      }          
  }
  }
  </code></pre>