Python | Numpy matrix.argsort ()



Using the Numpy matrix.argmax () method, we can find sorting elements in a given matrix that have one or more dimensions, and it will return the index value of the sorted elements.

Syntax: matrix.argsort()

Return: Return index number of sorted elements in matrix

Example # 1:
In this example we see that using the matrix.argsort () method we can find the sorted element in the given matrix and output the result as the index of the sorted array.

# import an important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np .matrix ( `[1, -2, 3, -4]` )

 
# using the matrix.argsort () method

geeks = gfg.argsort ()

 

print (geeks)

Exit:

 [[3 1 0 2]] 

Example # 2:

# import important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[-1, 2, 3; 4, -5, 6; 7, -8, 9] ` )

  
# using the matrix.argsort () method

geeks = gfg.argsort ()

 

print (geeks)

Exit:

 [[0 1 2] [1 0 2] [1 0 2]]