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