//  File: isort.C
//
//  Insertion Sort Routine

#include "array.h"
#include "sorts.h"

void InsertionSortPart(Array& A, int low, int high) {
   int i, j ;
   DATA key ;

   for (i = low+1 ; i <= high ; i++) {

      key = A[i] ;	// put A[i] in the "right" place

      j = i - 1 ;
      while ( j >= low && A[j] > key) {
         A[j+1] = A[j] ;
         j-- ;
      }

      A[j+1] = key ;
   }
}

void InsertionSort(Array& A) {
   
   InsertionSortPart(A, 0, A.length()-1) ;
}
