Regarding the sorting in multimap

I saw in the video that when he was printing the items in the map, these keys were in this order:

a->apple
a->angry

so if keys are same, the sorting should be done according to the values, but apple is lexicographically bigger than angry. So how are they sorted.

Sorting will not be done according to the values. It is done according to the keys.
In case of multimap, if there are duplicate keys, the one which was inserted first will be present before the one which was inserted later

1 Like

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.