sort

dragon.vm.tensorflow.sort(
  values,
  axis=- 1,
  direction='ASCENDING',
  name=None
)[source]

Return the sorted elements along the given axis.

By default, the last axis is chosen:

x = tf.constant([[1, 2, 3], [3, 2, 1]])
value1 = tf.sort(x)
value2 = tf.sort(x, axis=1)  # Equivalent

Sort in the inverse order if direction is DESCENDING:

x = tf.constant([1, 2, 3])
value1 = -tf.sort(-x)
value2 = tf.sort(x, direction='DESCENDING')  # Equivalent
Parameters:
  • values (dragon.Tensor) – The input tensor.
  • axis (int, optional, default=-1) – The axis to sort elements.
  • direction ({'ASCENDING', 'DESCENDING'}, optional) – The sorting direction.
  • name (str, optional) – The operation name.
Returns:

dragon.Tensor – The output tensor.