mindspore.ops.msort

mindspore.ops.msort(input)[source]

Sorts the elements in Tensor in ascending order of value along its first dimension.

ops.msort(t) is equivalent to ops.Sort(axis=0)(t)[0]. See also mindspore.ops.Sort().

Parameters

input (Tensor) – The input to sort, with float16 or float32 data type.

Returns

A tensor whose values are the sorted values, with the same shape and data type as input.

Raises

TypeError – If dtype of input is neither float16 nor float32.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore as ms
>>> from mindspore import ops
>>> import numpy as np
>>> input = ms.Tensor(np.array([[8, 2, 1], [5, 9, 3], [4, 6, 7]]), ms.float16)
>>> output = ops.msort(input)
>>> print(output)
[[4. 2. 1.]
 [5. 6. 3.]
 [8. 9. 7.]]