TypeError; Must use key word argument or key function in python 3.x

Looks like the problem is in this line.

self.__working_arr[num].sort( key = lambda a,b: cmp(a.weights, b.weights) )

The key callable should take only one argument. Try:

self.__working_arr[num].sort(key = lambda a: a.weights)

Leave a Comment