title: Method to sort an array in Java
body: <p>I've been working on a method that sorts an array from lowest to highest number.
  I came up with the code below but, as you probably guessed, it doesn't do what I expected.</p>
  
  <p>The logic I wished to apply goes as follows:</p>
  
  <p>Given I have an array, for example array {4,3,1,2,5}
  The code would compare, for example, array[0] (which would be four in this case) with each element in the array, </p>
  
  <pre><code>array[0]&gt;array[0] (4&gt;4=false), 
  array[0]&gt;array[1] (4&gt;3)= +1counter, 
  array[0]&gt;array[2] (4&gt;1)= +1counter, 
  array[0]&gt;array[3] (4&gt;2)= +1counter,
  array[0]&gt;array[4] (4&gt;5=false)
  
  counter = 3
  </code></pre>
  
  <p>So since the counter value its now 3, in the new array (array2, or arrayOrdered) number 4 would be in the third index.</p>
  
  <p>How should I fix it? Any help its more than appreciated!</p>
  
  <pre><code>public static int[] OrderArray(int[] array)
  {
  
      int[] array2=new int[array.length];
  
      for (int i=0; i&lt;array.length; i++)
      {
          int place=0;
          for (int j=0; j&lt;array.length;j++)
          {
              if (array[i]&gt; array[j])
              {
                  place = place+1;
              }
              array2[place] = array[i];
          }
  
      }
      return array2;
  }
  </code></pre>