In my last article have seen how we can leverage C++ STL to do selection sort on the vector of integers only. However, the selection sort wasn't very generic to accept vectors of any basic type and sort accordingly. The below program was an effort to make the same selection sort (ascending order) implementation for vectors of any type like vectors of integers, doubles, chars, etc. #include < iostream > #include < algorithm > #include < vector > template < class ForwardIterator1, class ForwardIterator2 > void iters_swap (ForwardIterator1 a, ForwardIterator2 b) { std::swap (*a, *b); } template < typename T > void selectionSort(std::vector< T > &v) { // Selection sort typedef typename std::vector ::value_type vt; typename std::vector ::iterator it = v.begin(); while(it != v.end()) { typename std::vector ::iterator i_Min = std::min_element (it, v.end()); iters_swap(i_Min, it); ++it; } } int main() {