How to Sort a Boolean Array in NumPy


In this example we will show how to sort a boolean array in Python NumPy.

Source Code

import numpy as np

n = np.array([True, False, True, False])

print(np.sort(n))

Output:

[False False  True  True]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments