Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Min and Max by lancelote
def min(*args, **kwargs):
key = kwargs.get("key", None)
if len(args) == 1:
return sorted(*args, key=key)[0]
else:
return sorted(args, key=key)[0]
def max(*args, **kwargs):
key = kwargs.get("key", None)
if len(args) == 1:
maximum = sorted(*args, key=key)[-1]
else:
result = sorted(args, key=key)
maximum = result[-1]
i = -2
try:
while key(result[i]) == key(maximum):
maximum = result[i]
i -= 1
except:
return result[-1]
return maximum
Aug. 6, 2015
Comments: