You can take a list of tuples and then sort them as if it were a multicard.
listAsMultimap=[]
Let me add some elements (tuples):
listAsMultimap.append((1,'a')) listAsMultimap.append((2,'c')) listAsMultimap.append((3,'d')) listAsMultimap.append((2,'b')) listAsMultimap.append((5,'e')) listAsMultimap.append((4,'d'))
Now figure it out.
listAsMultimap=sorted(listAsMultimap)
After listing you will receive:
[(1, 'a'), (2, 'b'), (2, 'c'), (3, 'd'), (4, 'd'), (5, 'e')]
This means that it works like a multimap!
Please note that, as in the case of several cards, here the values ββare also sorted in ascending order if the keys are the same (for the same key = 2, "b" is before "c", although we did not add them in this order.
If you want to get them in descending order, just change the sorted () function as follows:
listAsMultimap=sorted(listAsMultimap,reverse=True)
And after you get output like this:
[(5, 'e'), (4, 'd'), (3, 'd'), (2, 'c'), (2, 'b'), (1, 'a')]
Similarly, here the values ββare in descending order if the keys are the same.