public class Sort {
 
  public static void selectionSort(int[] list) {
   
    for(int i = 0; i < list.length; i++) {
    
      int smallest = i;
      
      // find the smallest element in
      // the unknown part of the array:
      // [i..list.length-1]
      for(int j = i + 1; j < list.length; j++) {
        if(list[smallest] > list[j]) {
          smallest = j;
        }
      }
      
      // put that element into its proper
      // position in the sorted part of the array
      int temp = list[smallest];
      list[smallest] = list[i];
      list[i] = temp;
    }
    Sorting.displayList(list);
  }
  
}
