[cpp][11_sorts] selection_sort, updated [prevent useless swap].

This commit is contained in:
Liam Huang 2018-10-17 09:37:30 +08:00
parent 1dfdd7e0fa
commit 2dfdfe8a89

View File

@ -53,7 +53,9 @@ void selection_sort(BidirIt first,
tag = itt;
}
}
std::swap(*it, *tag);
if (tag != it) {
std::swap(*it, *tag);
}
}
}