Ambiguous output using sort() function with user defined comparator in C++

Revision en2, by Nathan_McKane, 2020-10-15 00:04:57

I was trying a question on searching/sorting (Problem link) and i defined my own comparator for in-built sort(). It produced ambiguous output for the input (Error Code Link). However, when i changed the "<=" to "<" in my comparator, the code (Accepted Code Link) worked properly and was accepted. I dont know how this happened and what was the significance of changing the comparison condition.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Nathan_McKane 2020-10-15 00:04:57 8 Tiny change: 'sorting ([link](http' -> 'sorting ([Problem link](http'
en1 English Nathan_McKane 2020-10-15 00:04:00 628 Initial revision (published)