The built-in blocks max/ minseem greedy, that is, they return the first occurrence for the case when it is not 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 a language guarantee and can rely on cross-platform and higher versions, or is it implementation details?
source
share