The max
/min
built-ins seems to be greedy, i.e. they will return the first occurrence for the case when it is non-unique.
>>> x = [('spam', 1), ('egg', 0), ('potato', 1)]
>>> max(x, key=lambda v: v[1])
('spam', 1)
>>> max(reversed(x), key=lambda v: v[1])
('potato', 1)
Is this guaranteed by the language and can be relied on cross-platform and over versions, or is it implementation detail?