Sort, Search and & Counting

Sort, Search and Counting Functions

A.) Sorting functions
1.) sort(): It returns a sorted copy of the array. It takes parameters (array, axis, kind). Here for parameters axis means either along columns or rows or flattened array, the kind parameter(optional) means a type of sorting it will use like- quicksort, mergesort.
2.) argsort(): It returns the indices that would sort an array. It also has the same parameters as sort().
Sorting
B.)Searching functions
1.) agrmax(): It returns the indices of the maximum values along an axis. Similarly, agrmin() functions work to find the minimum.
2.) argwhere(): It finds the indices of array elements that are non-zero, grouped by element. Here this function takes a parameter as a condition and returns the indices of elements satisfying that condition. There are tons of searching and sorting functions like nonzero(), partition(), where(). So, for the core details of any function, you can go to the documentation of Numpy. The link is
C.)Counting function
1.) count_nonzero(): It returns the number of non-zero elements along the specified axis.
Close Menu