diff --git a/c-cpp/11_sorts/sorts.hpp b/c-cpp/11_sorts/sorts.hpp index dc965ba..15b41f2 100644 --- a/c-cpp/11_sorts/sorts.hpp +++ b/c-cpp/11_sorts/sorts.hpp @@ -53,7 +53,9 @@ void selection_sort(BidirIt first, tag = itt; } } - std::swap(*it, *tag); + if (tag != it) { + std::swap(*it, *tag); + } } }