How to Sort a 2-D NumPy Array


In this example we will show how to sort a 2-D NumPy array in Python.

Source Code

import numpy as np

n = np.array([[3, 1, 2], [5, 8, 6], [4, 3, 5]])

print(np.sort(n))

Output:

[[1 2 3]
 [5 6 8]
 [3 4 5]]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments