#ifndef CA_UWATERLOO_ALUMNI_DWHARDER_SELECTION_SORT_BASIC #define CA_UWATERLOO_ALUMNI_DWHARDER_SELECTION_SORT_BASIC namespace Sorting_algorithms { namespace Selection_sort { class Basic { public: template static void sort( Type *array, int n ) { for ( int i = 0; i < n; ++i ) { Type min = array[i]; int posn = i; for ( int j = i + 1; j < n; ++j ) { if ( array[j] < min ) { min = array[j]; posn = j; } } swap( array, i, posn ); } } private: template static void swap( Type *array, int i, int j ) { Type tmp = array[i]; array[i] = array[j]; array[j] = tmp; } }; } } #endif