title: Sorting an integer array in java, using selection sort. Cannot find my error
body: <p>I'm trying to learn code by making 'easy' exercises. I am trying to make a search algorithm using selection sort. When I follow the code inside my head it makes perfect sense, but when I run it, it does not order anything. For the array I am using an integer only array, it consist of random numbers and is of random length.</p>
  
  <pre><code>int currentMin;
      int currentMinIndex = 0;
      int temp;
      for(int i=0;i&lt;array.length-1;i++){
          currentMin = array[i]; 
          for(int j=i+1;j&lt;array.length-1;j++){
              if(array[j]&lt;currentMin){
                  currentMinIndex = j; 
                  currentMin = array[j];
              }
          }
          temp = array[currentMinIndex]; //I am aware this could be currentMin 
          array[currentMinIndex] = array[i];
          array[i] = temp;
      }
  </code></pre>
  
  <p>I hope someone will spot my mistake and tell me.
  (If you have other 'easy' exercises I could do, creativity is appreciated, however this post must stay on topic)</p>
  
  <p>Edit: I just noticed that in some weird way when the array is of large length it sorts but the last one. (array length vary because they are random)</p>