#include <algorithm> template<typename Iterator> void bubbleSort(Iterator first, Iterator last) { Iterator i, j; for (i = first; i != last; i++){ for (j = first; j < i; j++){ if (*i < *j) std::iter_swap(i, j); // or std::swap(*i, *j); } } }

Skip to content
# C++: Bubble Sort

*Related*

Posted on by TFE Times