To sort an STL container with std::sort(), the custom comparator used must satisfy the Compare named requirement. Specifically,
comp(a, b): Establishes strict weak ordering relation with the following properties:
- For all a, comp(a,a)==false
When sorting by whole values descending (specifically, sortBy: -1), we do the following negation:
Simply negating ascending is not correct, because when comparing two equal values, getLessThan() should return false for both.
This logic error triggers a fatal assertion on Windows debug builds, because the MSVC STL implementation checks for the validity of the comparator.