From the experiment, I realized that when in the case of a tie, the python selects by order (for example, the element that comes first in the list) Is there a way, when in the case of binding, I can select the element randomly so that it is not deterministic and based on order ?
eg.
l = [ ([1], 10) , ([2], 3), ([3], 9), ([4], 10)] max(l, key=lambda x: x[1])
each run of this can be returned ([4], 10) or ([1], 10) and not always ([1], 10)
source share