I have a Python list of tuples:
vals = [(40.69, array([1.34, 1.516, 0.000135,....])), (213.69, array([0.34, 1.51256, 0.0110135,....])...]
vals.sort()
The first element in the tuple is a float
and the second element is a numpy ndarray
. There are 784 elements in the array.
I get ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
at vals.sort
. I am trying to sort on the first element in the tuple itself. This code works when I use a smaller dataset that produces only 13 elements in the ndarray. I can't figure out why it should throw this particular error if the number of elements is more.
Can anyone please help me out?