temp[::-1].sort() sorts the array in place, whereas np.sort(temp)[::-1] creates a new array.
In [25]: temp = np.random.randint(1,10, 10)
In [26]: temp
Out[26]: array([5, 2, 7, 4, 4, 2, 8, 6, 4, 4])
In [27]: id(temp)
Out[27]: 139962713524944
In [28]: temp[::-1].sort()
In [29]: temp
Out[29]: array([8, 7, 6, 5, 4, 4, 4, 4, 2, 2])
In [30]: id(temp)
Out[30]: 139962713524944
Answer from Padraic Cunningham on Stack OverflowNumPy
numpy.org › doc › stable › reference › generated › numpy.sort.html
numpy.sort — NumPy v2.5 Manual
Sort order. If True, the returned array will be sorted in descending order. If False or None, the returned array will be sorted in ascending order. Values that are NaN are sorted to the end for both orders.
03:03
Efficiently sorting a numpy array in descending order? - YouTube
Efficiently sorting a numpy array in descending order?
06:08
NumPy Sorting Arrays - YouTube
03:33
NumPy Array Sorting Tutorial: Master np.sort() for Beginners | ...
12:19
Python NumPy Tutorial 14 - Sorting NumPy Array with Examples - YouTube
Programiz
programiz.com › python-programming › numpy › methods › sort
NumPy sort()
The sort() method sorts an array in ascending order. import numpy as np array = np.array([10, 2, 9, -1])
NumPy
numpy.org › doc › stable › reference › generated › numpy.argsort.html
numpy.argsort — NumPy v2.5 Manual
Sort order. If True, the returned array will be sorted in descending order. If False or None, the returned array will be sorted in ascending order. Values that are NaN are sorted to the end for both orders.
Codecademy
codecademy.com › article › sorting-and-unary-operations-in-num-py
Sorting and Unary Operations in NumPy | Codecademy
The numpy.argsort() function returns the indices of the elements in an array that would sort the array in ascending order.
Top answer 1 of 12
231
temp[::-1].sort() sorts the array in place, whereas np.sort(temp)[::-1] creates a new array.
In [25]: temp = np.random.randint(1,10, 10)
In [26]: temp
Out[26]: array([5, 2, 7, 4, 4, 2, 8, 6, 4, 4])
In [27]: id(temp)
Out[27]: 139962713524944
In [28]: temp[::-1].sort()
In [29]: temp
Out[29]: array([8, 7, 6, 5, 4, 4, 4, 4, 2, 2])
In [30]: id(temp)
Out[30]: 139962713524944
2 of 12
185
>>> a=np.array([5, 2, 7, 4, 4, 2, 8, 6, 4, 4])
>>> np.sort(a)
array([2, 2, 4, 4, 4, 4, 5, 6, 7, 8])
>>> -np.sort(-a)
array([8, 7, 6, 5, 4, 4, 4, 4, 2, 2])
Medium
medium.com › @whyamit404 › sorting-numpy-arrays-by-column-using-numpy-sort-c45a44660dcc
Sorting NumPy Arrays by Column Using numpy.sort() | by whyamit404 | Medium
February 26, 2025 - By now, you should feel comfortable ... it’s ascending, descending, or using a specific column. The real beauty of argsort() lies in its flexibility, which is why it's one of the most powerful tools for sorting data. ... You might be wondering: “Can I sort more than one column at once?” The answer is yes! You can use np.lexsort() to perform multi-key sorting. Here's how: import numpy as np arr ...
NumPy
numpy.org › devdocs › reference › generated › numpy.sort.html
numpy.sort — NumPy v2.6.dev0 Manual
Sort order. If True, the returned array will be sorted in descending order. If False or None, the returned array will be sorted in ascending order. Values that are NaN are sorted to the end for both orders.
Codecademy
codecademy.com › docs › python:numpy › ndarray › .sort()
Python:NumPy | ndarray | .sort() | Codecademy
October 30, 2025 - The .sort() method sorts a NumPy array in-place in ascending order along a specified axis.
NumPy
numpy.org › devdocs › reference › generated › numpy.argsort.html
numpy.argsort — NumPy v2.6.dev0 Manual
Sort order. If True, the returned array will be sorted in descending order. If False or None, the returned array will be sorted in ascending order. Values that are NaN are sorted to the end for both orders.
Python Tutorial
pythontutorial.net › home › python numpy › numpy sort()
NumPy sort() - Python Tutorial
August 10, 2022 - import numpy as np a = np.array([2, 3, 1]) b = np.sort(a)[::-1] print(b)Copy · Output: [3 2 1]Copy · In this example: First, the sort() function sorts the elements in the array a in ascending order (from low to high) Then, the slice [::-1] ...
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .sort()
Python:NumPy | Built-in Functions | .sort() | Codecademy
July 25, 2025 - It depends which method you use: numpy.sort(array) returns a sorted copy without modifying the original, while array.sort() sorts the array in-place. The .sort() method only sorts in ascending order.
Programiz
programiz.com › python-programming › numpy › methods › argsort
NumPy argsort()
The argsort() method in NumPy sorts the array elements in ascending order and returns indices of the sorted elements. The argsort() method in NumPy sorts the array elements in ascending order and returns indices of the sorted elements.
Hyperskill
hyperskill.org › university › numpy › numpy-array-sort
NumPy Array Sort
September 4, 2024 - By default, np.sort() sorts the array in ascending order, returning a new sorted array without modifying the original array. You can also specify the axis parameter to sort the array along a particular axis. NumPy is a powerful tool for data manipulation and performing various mathematical ...