[cpp][11_sorts] selection_sort, updated [prevent useless swap].
This commit is contained in:
parent
1dfdd7e0fa
commit
2dfdfe8a89
@ -53,7 +53,9 @@ void selection_sort(BidirIt first,
|
||||
tag = itt;
|
||||
}
|
||||
}
|
||||
std::swap(*it, *tag);
|
||||
if (tag != it) {
|
||||
std::swap(*it, *tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user