How to use a custom function in max(x, key=custom_function) function?
问题 I have a custom data type, say: mytime , which represent hours and minutes, such as 29:45, it is 29 hours and 45 minutes. I want to use max built-in function to find the item in a list of lists, whose sum of its elements is the greatest, where all lists contain values of mytime type. x = [[a, b], [c, d]] a,b,c,d are of mytime type. max(x, key=sum) won't work here, because a,b,c,d, are not integers. If I type a + b at python command line, I get the sum of these two time values, result is of