cant understand the logic of return p1.first<p2.first as any of the two can contain the shorter word(alice as compared to bob) so it doesnt contradict the “<” operator used
Doubt in comparators
@ANIKET_DALAL p1.first<p2.first will sort according to lexicographic order/dictionary order of words which is not just dependent of length of word but on characters also.
If you want the sorting to be opposite of that in dictionary order then you would write p1.first>p2.first
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.