argsort

dragon.argsort(
  inputs,
  axis=- 1,
  descending=False,
  **kwargs
)[source]

Return the index of sorted elements along the given axis.

By default, the last axis is chosen:

x = dragon.constant([[1, 2, 3], [3, 2, 1]])
index1 = dragon.argsort(x)
index2 = dragon.argsort(x, axis=1)  # Equivalent

Sort in the inverse order if descending is True:

x = dragon.constant([1, 2, 3])
index1 = dragon.argsort(-x)
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.