I'm trying to sort a list of tuples by the first value in ascending or descending order based on the order variable in the input being 'ascending' or 'descending'. i tried something like this code below but didn't work. can you please help me correct this ?
sample input: [(2.0, array([1., 0., 0.])), (1.0, array([0., 1., 0.])), (3.0, array([0., 0., 1.]))]
[code]
def sort_eigen_pairs(Ep, order = 'ascending'):
if(order=='descending'):
Ep = Ep.sort(reverse=True)
else:
Ep=Ep.sort()
return Ep