-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Syntax:
np.sort(a, axis=-1, kind=None, order=None)
a: Input array.
axis: Axis along which to sort. Default is -1 (last axis).
kind: Sorting algorithm: 'quicksort', 'mergesort', 'heapsort', 'stable'. Default is 'quicksort'.
order: When a is a structured array, this specifies which fields to compare first.
Example:
import numpy as np
sorted_arr = np.sort(np.array([3, 1, 2, 5]))
print(sorted_arr)
[1 2 3 5]
import numpy as np
arr = np.array([[3, 1, 2], [9, 5, 7]])
sorted_2d = np.sort(arr, axis=1)
print(sorted_2d)
[[1 2 3]
[5 7 9]]
Metadata
Metadata
Assignees
Labels
No labels