Reputation: 21
Shouldn't it be the opposite? what do we mean by less and greater in detail when we use them as comparators I don't understand the complete explanation for this, could someone please help me out.
Upvotes: 2
Views: 377
Reputation: 122133
It is purley a matter of convention to use the comparator to decide whether one element a
comes before another element b
. Thats why for increasing order a < b
or std::less
is used and for decreasing order a > b
/ std::greater
.
If the convention was the opposite: Use the comparater to decide which element comes last. Then <
would result in decreasing order and >
would result in increasing order.
Upvotes: 1