How to Sort NumPy Arrays of Strings


In this example, we will learn how to sort NumPy arrays of strings in Python.

Source Code

import numpy as np

n = np.array(['z', 'r', 'Python', 'apple', 'Java'])

print(np.sort(n))

Output:

['Java' 'Python' 'apple' 'r' 'z']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments