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