title: Fastest strategy to form and sort an array of positive integers
body: <p>In Java, what is faster: to create, fill in and then sort an array of ints like below</p>
  
  <pre><code>int[] a = int[1000];
  for (int i = 0; i &lt; a.length; i++) {
      // not sure about the syntax
      a[i] = Maths.rand(1, 500) // generate some random positive number less than 500
  }
  a.sort(); // (which algorithm is best?)
  </code></pre>
  
  <p>or insert-sort on the fly</p>
  
  <pre><code>int[] a = int[1000];
  for (int i = 0; i &lt; a.length; i++) {
      // not sure about the syntax
      int v = Maths.rand(1, 500) // generate some random positive number less than 500
      int p = findPosition(a, v); // where to insert
      if (a[p] == 0) a[p] = v;
      else {
          shift a by 1 to the right
          a[p] = v;
      }
  }
  </code></pre>