title: Sorting multidimensional array without sort method?
body: <p>I was tasked with creating a 2D array (10-by-10), filling it with random numbers (from 10 to 99), and other tasks. I am, however, having difficulty sorting each row of this array in ascending order without using the array sort() method. </p>
  
  <p>My sorting method does not sort. Instead, it prints out values diagonally, from the top leftmost corner to the bottom right corner. What should I do to sort the numbers?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class Program3 
  {
      public static void main(String args[])
      {
          int[][] arrayOne = new int[10][10];
          int[][] arrayTwo = new int[10][10];
          arrayTwo = fillArray(arrayOne);
  
          System.out.println("");
  
          looper(arrayTwo);
  
          System.out.println("");
  
          sorter(arrayTwo);
  
  
      }
      public static int randomRange(int min, int max)
      {
          // Where (int)(Math.random() * ((upperbound - lowerbound) + 1) + lowerbound);
          return (int)(Math.random()* ((max - min) + 1) + min);
      }
      public static int[][] fillArray(int x[][])
      {
          for (int row = 0; row &lt; x.length; row++)
          {
              for (int column = 0; column &lt; x[row].length; column++)
              {
                  x[row][column] = randomRange(10,99);
                  System.out.print(x[row][column] + "\t");
              }
              System.out.println();
          }
          return x;
      }
      public static void looper(int y[][])
      {
          for (int row = 0; row &lt; y.length; row++)
          {
              for (int column = 0; column &lt; y[row].length; column++)
              {
                  if (y[row][column]%2 == 0)
                  {
                      y[row][column] = 2 * y[row][column];
  
                      if (y[row][column]%10 == 0)
                      {
                          y[row][column] = y[row][column]/10;
  
                      }
                  }
                  else if (y[row][column] == 59)
                  {
                      y[row][column] = 99;
                  }
                  System.out.print(y[row][column] + "\t");
              }
              System.out.println();
          }
          //return y;
      }
      public static void sorter(int[][] z)
      {
          int temp = 0;
          int tempTwo = 0;
          int lowest; 
          int bravo = 0;
          int bravoBefore = -1;
  
          for (int alpha = 0; alpha &lt; z.length; alpha++)
          {
              //System.out.println(alpha + "a");
  
              lowest = z[alpha][bravoBefore + 1];
              bravoBefore++;
              for (bravo = alpha + 1; bravo &lt; z[alpha].length; bravo++)
              {
                  //System.out.println(alpha + "b");
                  temp = bravo;
  
                  if((z[alpha][bravo]) &lt; lowest)
                  {
  
                      temp = bravo;
                      lowest = z[alpha][bravo];
                      //System.out.println(lowest + " " + temp);
                      //System.out.println(alpha + "c" + temp);
                      tempTwo = z[alpha][bravo];
                      z[alpha][bravo] = z[alpha][temp];
                      z[alpha][temp] = tempTwo;   
                      //System.out.println(alpha + "d" + temp);
                  }
  
              }
  
              System.out.print(z[alpha][bravoBefore] + "\t");
          }
          /*
          for (int alpha = 0; alpha &lt; z.length; alpha++)
          {
              for (int bravo = 0; bravo &lt; z.length - 1; bravo++)
              {
                  if(Integer.valueOf(z[alpha][bravo]) &lt; Integer.valueOf(z[alpha - 1][bravo]))
                  {
                      int[][] temp = z[alpha - 1][bravo];
                      z[alpha-1][bravo] = z[alpha][bravo];
                      z[alpha][bravo] = temp;
                  }
              }
          }
           */
      }
  }
  </code></pre>