// File: selectionsort.cpp // // Selection Sort Routines #ifndef SELECTION_SORT_H #define SELECTION_SORT_H template void SelectionSort(T A[], int low, int high) { int i, j, min ; T temp ; for (i = low ; i < high ; i++) { // find index of ith smallest number min = i ; for (j = i+1 ; j <= high ; j++) { if (A[j] < A[min]) min = j ; } // swap the ith smallest number to the right place temp = A[min] ; A[min] = A[i] ; A[i] = temp ; } } #endif