// selection sort
public class Sorter
{
	public static void sort(Comparable[] objects) 
	{
	    int min;
	    Comparable temp;
	    //select location of next sorted value
	    for (int i = 0; i < objects.length-1; i++)
	    {
	      min = i;
	      //find the smallest value in the remainder of
	      //the array to be sorted
	      for (int j = i+1; j < objects.length; j++)
	      {
	        if ( objects[j].compareTo(objects[min]) < 0) 
	        {
	          min = j;
	        }
	      }
	      //swap two values in the array
	      temp = objects[i];
	      objects[i] = objects[min];
	      objects[min] = temp;
	    }
	    
	    System.out.println("Printing sorted result");
	    for (int i = 0; i < objects.length; i++)
	    {
	      System.out.println(objects[i]);
	    } 
	}
  public static void main(String[] args)
  {
    //int[] numbers = {16,3,19,8,12};
    
    // create a Wrapper for Integer objects
    Integer[] numbers = {16,3,19,8,12};
    // goal: use compareTo for sorting
    // negative if less than, 0 if equal, positive if greater than
 
    Sorter.sort(numbers);
    String[] strings = {"Carson", "Thompson", "Kamara", "Mi"};
    Sorter.sort(strings);
    Double[] bunchOfDoubles = {3.14159265,2.7,3.564,7.162};
    Sorter.sort(bunchOfDoubles);
  }
}

