import SimpleInput;
import SimpleOutput;

public class SortShell1 {
// a sorting shell for experiments with the insertion and selection sorts

public static void insertionSort (int [] a) {
// method to sort using the insertion sort
   for (int k = 1; k < a.length; k++) {
      int item = a[k];
      int i = k-1;
      while ((i >= 0) && a[i] > item){
         a[i+1] = a[i];
         i--;
      }
      a[i+1] = item;
   }
} // insertionSort

public static void main (String [] args) {
    // declarations: two arrays and I/O;
    int size = 12;
    int [] c = new int [size];
    SimpleOutput out = new SimpleOutput ();
    SimpleInput  in  = new SimpleInput  ();

    // initial arrays to same values by reading and copying
    out.println ("Please enter " + size + " integer values to sort");
    for (int i = 0; i < size; i++) {
       c[i] = in.readInt();
    }

    // sort and print first array
    insertionSort (c);
    out.println ("Result of Insertion Sort:");
    for (int i = 0; i < size; i++) 
        out.print(c[i] + "\t");
    out.println();

} // main

} // SortShell1
