How can this be achieved without a custom comparator?
Q7. Vector STL#7
@SMRITI using 2nd option sort function directly sorts the pair vector on basis of first value in pair.
i hope its clear if yes dont forget to mark the doubt resolved 
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.