// File: insertionsort.cpp // // Insertion Sort Routine #ifndef INSERTION_SORT_CPP #define INSERTION_SORT_CPP template void InsertionSort(T A[], int low, int high) { int i, j ; T 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 ; } } #endif