I would like to sort a very large array of floats. When I use sorted, the result is a list. However, I want a new array of floats.
Here is a short example:
import numpy as np
xmaxp = np.array([25.0, 5.0, 1.0],dtype=float)
xmaxp_sorted = sorted(xmaxp)
CodePudding user response:
as everybody else mentioned, use numpy sort method :
import numpy as np
xmaxp = np.array([25.0, 5.0, 1.0], dtype=float)
xmaxp_sorted = np.sort(xmaxp)
result :
[ 1. 5. 25.]
<class 'numpy.ndarray'>
CodePudding user response:
I think you can use np.array
np.array(xmaxp_sorted)
