title: Using a For Loop to Manually Sort an Array - Java
body: <p>I'm having trouble manually sorting the array with a for loop. It works except for the first and last number. Here's my code:</p>
  
  <pre><code>Scanner numInput = new Scanner(System.in);
  
  int tempVar, num;
  String numbersString;
  int[] numbers = {4, 11, 13, 12, 17, 35, 15, 7, 19, 3, 45};
  
  for (int i = 0; i &lt; numbers.length - 1; i++)
  {
    for(int j = 0; j &lt; numbers.length - 1; j++)
    {
      if(numbers[i] &lt; numbers[j + 1])
      {
        tempVar = numbers [j + 1];
        numbers [j + 1]= numbers [i];
        numbers [i] = tempVar;
      }
    }
  } 
  
  numbersString = Arrays.toString(numbers);
  
  System.out.println(numbersString);
  </code></pre>