#ifndef SORTERH #define SORTERH #include //for iterator_traits using namespace std; /* ITERATOR must be random access. typename iterator_traits::value_type must be copy constructable and assignable. COMPARE must be a binary predicate accepting arguments of type typename iterator_traits::value_type. */ template void sorter(ITERATOR first, ITERATOR last, COMPARE comp) { while (first < --last) { for (ITERATOR it = first; it < last; ++it) { if (comp(it[1], it[0])) { const typename iterator_traits::value_type temp = it[0]; it[0] = it[1]; it[1] = temp; } } } } #endif