Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

numpy sort

import numpy as np

arr = np.array([3, 2, 0, 1])
print(np.sort(arr))
# output [0 1 2 3]

arr = np.array(['banana', 'cherry', 'apple'])
print(np.sort(arr))
# output ['apple' 'banana' 'cherry']

arr = np.array([True, False, True])
print(np.sort(arr))
# output [False  True  True]

arr = np.array([[3, 2, 4], [5, 0, 1]])
print(np.sort(arr))
# output
# [[2 3 4]
#  [0 1 5]]
Source by codefreelance.net #
 
PREVIOUS NEXT
Tagged: #numpy #sort
ADD COMMENT
Topic
Name
4+9 =