NumPy TutorialLesson 15Free preview
NumPy Array Sort
This lesson is part of NumPy · All levels
Summary
Returns a copy of the sorted array without changing the original array. You can sort by row or column over the axis parameter, and then choose the algorithm with the kind parameter. The np.argsort function is useful for obtaining an index of elements after sorting, for example to sort by other columns.
Key points
- Returns the ordered copy, the original array is unchanged.
- The parameter axis=0 sorts per column, axis=1 sorts per line.
- Returns the result index.
- To sort in place, use arr.sort().
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.