title: Swapping array values with minimum value
body: <p>So what I'm trying to do is to sort an array by going through the whole array and each time swap the value with the minimum value in the array. I've created a method to find minValue, but I'm not sure how to swap that value with my current value. This is probably a horrible explanation, but here's the code:</p>
  
  <pre><code>public static int findMin(int[] numList, int start, int end){
  
      int minIndex = numList[0];
      for (int i = start; i &lt; end; i++) {
          if(numList[i] &lt; minIndex){
              minIndex = numList[i];
          }
      }
  
      return minIndex;
  }
  </code></pre>
  
  <p>And my loop which is supposed to sort the array:</p>
  
  <pre><code>for (int i = 0; i &lt; numList.length; i++) {
          int minIndex = findMin(numList,i,10);
          numList[i] = minIndex;
      }
  </code></pre>
  
  <p>So as you can see, this only replaces <code>numList[i]</code> with the minValue. So how can I swap the value already in numList[i] with wherever in the array minValue was found?</p>
  
  <p>Thanks!</p>