sort¶
dragon.
sort
(
inputs,
axis=- 1,
descending=False,
**kwargs
)[source]¶Return the sorted elements along the given axis.
axis
could be negative:# A negative axis is the last-k axis x = dragon.constant([[1, 2, 3], [3, 2, 1]]) value1, index1 = dragon.sort(x, axis=1) value2, index2 = dragon.sort(x, axis=-1) # Equivalent
Use
descending
to sort in the inverse order:x = dragon.constant([1, 2, 3]) _, index1 = dragon.sort(-x, descending=False) _, index2 = dragon.sort(x, descending=True) # Equivalent
- Parameters:
- inputs (dragon.Tensor) – The input tensor.
- axis (int, optional, default=-1) – The axis to sort.
- descending (bool, optional, default=False) – Sort in the descending order or not.
- Returns:
Sequence[dragon.Tensor] – The value and index tensor.