NumPy: Sorting Arrays Using numpy.ndarray.sort()

It is used to sort an array,in-place.

Syntax:

ndarray.sort(axis=-1, kind='quicksort', order=None)

Example:

import numpy as np
a=np.array([[1,4,3],[2,6,5]])
a.sort(axis=1)
print(a)

Output:

[[1 3 4]
 [2 5 6]]
Tue, 09/07/2021 - 20:19

Authored by

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.