When using the max()
function in Python to find the maximum value in a list (or tuple, dict etc.) and there is a tie for maximum value, which one does Python pick? Is it random?
This is relevant if, for instance, one has a list of tuples and one selects a maximum (using a key=
) based on the first element of the tuple but there are different second elements. How does Python decide which one to pick as the maximum?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…