I was trying to run some code and sort an array, below is the code. Online it says that an array can be sorted using this way but when I run this code, the output is None instead of the sorted code, can someone explain why? In Jupyter Notebook it works fine when I tested it. Both ways don't work - why is that ?
import numpy as np
arr = np.array([3, 7, 6, 8, 9, 1, 2, 3])
arr_sorted = arr.sort()
print(arr_sorted)
# alternative way
arr_sorted2 = np.ndarray.sort(arr)
print(arr_sorted2)
Additionally I found that this works instead - but I still don't know the why.
print(np.sort(arr))
ab = np.sort(arr)
print(ab)
