I have the following kind of dictionary
import operator
my_dict = {'a':np.array((1,2)),'b':np.array((3,4))}
and I need to sorted based on the 1st column of the arrays. I can sort this other dictionary
my_dict2 = {'a':np.array((1)),'b':np.array((3))}
using
sorted(my_dict2.items(), key=operator.itemgetter(1),reverse=True)
but trying the same approach with my_dict, i.e.
sorted(my_dict.items(), key=operator.itemgetter(1),reverse=True)
throws the error message
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I have tried to play with the argument in itemgetter, but I cannot order my_dict.