Python numpy.sort()

In this tutorial, I’ll tell you about Python numpy sort() function. It sort an array or you can say it puts items in an ordered sequence, like asc or desc and numeric or alphabetic



The syntax of python numpy sort function is




numpy sort function can take four parameters

  • array: it numpy array , which you want to be sorted
  • axis(Optional): It represent the axis along which to sort, if axis is equal to None(axis=None), array will be flattend before sorting, By default, axis is -1
  • kind(Optional): It represent the sorting algorithm(quicksort, mergesort, heapsort, stable). By default, its ‘quicksort’.
  • Order(optional): It is used when we have need to sort a structured array.



Check the examples below to understand


Example #1

Sorting a 1-D Array using numpy sort() function


Example #2

Sorting a 2-D Array using numpy sort() function


Example #3

sorting a structured array using order parameter


Start with Numpy

Python numpy.linspace()