What gp probably messed up is the one of the guarantees of a strict weak ordering:
- Irreflexivity: comp(a, a) == false for all a
- Transitivity: if comp(a, b) == true and comp(b, c) == true then comp(a, c) == true
- Asymmetry: if comp(a, b) == true then comp(b, a) == false
std::sort can assume that all these requirements are true and does not have to care about what happens if they don't.
[0] https://en.cppreference.com/w/cpp/named_req/Compare
What gp probably messed up is the one of the guarantees of a strict weak ordering:
- Irreflexivity: comp(a, a) == false for all a
- Transitivity: if comp(a, b) == true and comp(b, c) == true then comp(a, c) == true
- Asymmetry: if comp(a, b) == true then comp(b, a) == false
std::sort can assume that all these requirements are true and does not have to care about what happens if they don't.
[0] https://en.cppreference.com/w/cpp/named_req/Compare