The char.chararray.argsort()
method in Python returns the indices that sort the input array. In other words, the char.chararray.argsort()
method returns an array of indices along a given axis
with the same shape as the input array in sorted order.
char.chararray.argsort(axis=- 1, kind=None, order=None)
The char.chararray.argsort()
method takes the following parameter values:
axis
: This is the axis that is to be sorted. The default value is given as -1
, which specifies the last used axis. The None
value is used for a flattened array. This is optional.kind
: This specifies the algorithm to be used for sorting. It takes the following values: quicksort
, mergesort, heapsort
, and stable
. It takes quicksort
as its default value. This is optional.order
: This specifies the order in which to compare the fields.import numpy as np# creating an input arrayx = np.array([[ 4, 6, 2], [ 5, 1, 3]])# implementing the char.chararray.argsort() methodmyarray = x.argsort(axis=1, kind='heapsort')# printing the original arrayprint(x)# printing the sorted arrayprint(myarray)