Returns the indices of a tensor that give its sorted order along an axis.

Used in the notebooks

Used in the tutorials
values = [1, 10, 26.9, 2.8, 166.32, 62.3]
sort_order = tf.argsort(values)
array([0, 3, 1, 2, 5, 4], dtype=int32)

For a 1D tensor:

sorted = tf.gather(values, sort_order)
assert tf.reduce_all(sorted == tf.sort(values))

For higher dimensions, the output has the same shape as values, but along the given axis, values represent the index of the sorted element in that slice of the tensor at the given position.

mat = [[30,20,10],