title: Sorting an array into a 2nd array in Java
body: <p>I need to make 2 arrays and sort one into the other in ascending order and display it. I've managed to move ar[] into sorted[], but I can't get it to actually sort.<br>
  Here's what I have so far:</p>
  
  <pre><code>public class SortArray
  {
      public static void main(String argv[])
      {
          int ar[] = { 7, 5, 2, 8, 4, 9, 6 };
          int sorted[] = new int[7];
  
          for (int i=0; i&lt;ar.length-1; i++)
          {
              int smallest = 1000000;
              int index    = 0;
  
              for (int j=i+1; j&lt;sorted.length; j++)
              {
                  if (ar[i] &lt; smallest)
                  {
                      smallest=i;
  
                      int tmp = ar[i];
                      ar[i] = sorted[j];
                      sorted[j] = tmp;
                  }
              }
          }
  
          for(int i=0; i&lt;sorted.length; i++)
          {
              System.out.println("sorted[" + i + "] = " + sorted[i]);
          }
      }
  }
  </code></pre>