@Kevin, - / @featuresky:
functools.cmp_to_key cmp ( ), , 2 -. ; :
self.__working_arr[num].sort( key = lambda a,b: cmp(a.weights, b.weights) )
:
from functools import cmp_to_key
[...]
def cmp(x, y): return (x > y) - (x < y)
self.__working_arr[num].sort(key=cmp_to_key(lambda a,b: cmp(a.weights, b.weights)))
, python python2. , , , , "" .
OTOH python2 ( python3), /, "" .
Besides the fact that it works, I certainly would not recommend the widespread use of this hack! But I thought it was worth sharing.
source
share