title: Proper method to timing how long a sorting algorithm takes
body: <p>(Using Java)</p>
  
  <p>I'm testing sorting arrays to see literally how fast different sorting arrays take.  I want to weed out the erroneous times, so ideally I would like to start a timer, run the sort in a loop of say 100 times, stop the timer, then divide by 100 to get a pretty accurate measure.</p>
  
  <p>The problem is if I were to loop the same array, it'll sort properly the first time, then each sort after, it'll keep sorting the already sorted array, which isn't what I want.</p>
  
  <p>Maybe I'm missing an obvious solution, but is there any way I can make it keep sorting the same initial randomized array?</p>
  
  <p>I thought about reassigning the newly sorted array back to the initial random array each time, but that would mess up my timer..</p>
  
  <p>thanks for any suggestions</p>
  
  <p>what i would like to do:</p>
  
  <pre><code>        startTime = System.nanoTime();
          for(int i=0; i&lt;cntr; i++) {
              sort array
          }
          endTime = System.nanoTime();
          time = (endTime - startTime)/cntr;
  </code></pre>