
import java.util.*;


public class HelpSelectionSort
{

  // ***** main method *****
  public static void main(String[] arguments)
  {
      System.out.println("Selection Sort");
      System.out.println();
      System.out.println();
      
      int [] ray = {98, 85, 68, 74, 88};
      
      System.out.println(Arrays.toString(ray));
      
      for (int i=0;  i<ray.length-1;  i++) // each i loop is a pass
      {
          // find the position of the smallest number in the list i to end
          // (select the position of the smallest number from i to end of the list)
          
          int posOfSmallest = i; // smallest so far
          
          for (int k = i+1;  k<ray.length;  k++)
          {
              if (ray[k] < ray[posOfSmallest]) // if ray[k] is smaller, then save it
              {
              
                  posOfSmallest = k;
              }
            
          }
        
          // now swap the i position with the k position
          int temp = ray[i];
          ray[i] = ray[posOfSmallest]; // could we put something else here?
          ray[posOfSmallest] = temp;
                 
      }
      
      System.out.println();
      System.out.println(Arrays.toString(ray));
  }



} // end of class HelpPrintf




