3
votes

I have a numpy array like:

A = array([[-inf,  4,  5,  10, -inf, 1],
            [-inf,  2,  6, 8, -inf, 1],
            [-inf,  4,  -inf,  10, -inf, 100]
      ])

I need to sort in a decreasing order: 

A = array ([ 10,5,4,1,-inf,-inf], 
          [8,6,2,1,-inf,-inf],
           [100,10,4,-inf,-inf,-inf]])

Here -inf is float('-inf') How Do I do this?

I tried this: sorted(A, key=lambda listA: len(listA), reverse=True)

But I am not getting the sorted array. Can someone please tell me how to do this?

1

1 Answers