Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <functional>
- template<typename ForwardIt, typename Compare>
- void bubble_sort(ForwardIt first, ForwardIt last, Compare comp) {
- for(ForwardIt x = first; x != last; ++x) {
- for(ForwardIt y = first; y != last; ++y) {
- if(comp(*x, *y)) {
- std::iter_swap(x, y);
- }
- }
- }
- }
- template<typename ForwardIt>
- void bubble_sort(ForwardIt first, ForwardIt last) {
- bubble_sort(first, last, std::less<>());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement