# tf.sort

Sorts a tensor.

#### Usage:

````a = [1, 10, 26.9, 2.8, 166.32, 62.3]`
`tf.sort(a).numpy()`
`array([  1.  ,   2.8 ,  10.  ,  26.9 ,  62.3 , 166.32], dtype=float32)`
```
````tf.sort(a, direction='DESCENDING').numpy()`
`array([166.32,  62.3 ,  26.9 ,  10.  ,   2.8 ,   1.  ], dtype=float32)`
```

For multidimensional inputs you can control which axis the sort is applied along. The default `axis=-1` sorts the innermost axis.

````mat = [[3,2,1],`
`       [2,1,3],`
`       [1,3,2]]`
`tf.sort(mat, axis=-1).numpy()`
`array([[1, 2, 3],`
`       [1, 2, 3],`
`       [1, 2, 3]], dtype=int32)`
`tf.sort(mat, axis=0).numpy()`
`array([[1, 1, 1],`
`       [2, 2, 2],`
`       [3, 3, 3]], dtype=int32)`
```

`values` 1-D or higher numeric `Tensor`.
`axis` The axis along which to sort. The default is -1, which sorts the last axis.
`direction` The direction in which to sort the values (`'ASCENDING'` or `'DESCENDING'`).
`name` Optional name for the operation.

A `Tensor` with the same dtype and shape as `values`, with the elements sorted along the given `axis`.

`tf.errors.InvalidArgumentError` If the `values.dtype` is not a `float` or `int` type.
`ValueError` If axis is not a constant scalar, or the direction is invalid.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]