msort

paddle. msort ( input: Tensor, *, out: Tensor | None = None ) Tensor [source]

Sorts the input along the given axis = 0, and returns the sorted output tensor. The sort algorithm is ascending.

Parameters
  • input (Tensor) – An input N-D Tensor with type float32, float64, int16, int32, int64, uint8.

  • out (Tensor, optional) – The output tensor.

Returns

Tensor, sorted tensor(with the same shape and data type as input).

Examples

>>> import paddle

>>> x = paddle.to_tensor([[[5,8,9,5],
...                        [0,0,1,7],
...                        [6,9,2,4]],
...                       [[5,2,4,2],
...                        [4,7,7,9],
...                        [1,7,0,6]]],
...                      dtype='float32')
>>> out1 = paddle.msort(input=x)
>>> print(out1.numpy())
[[[5. 2. 4. 2.]
  [0. 0. 1. 7.]
  [1. 7. 0. 4.]]
 [[5. 8. 9. 5.]
  [4. 7. 7. 9.]
  [6. 9. 2. 6.]]]

>>> out2 = paddle.empty_like(x)
>>> paddle.msort(input=x, out=out2)
>>> print(out2.numpy())
[[[5. 2. 4. 2.]
  [0. 0. 1. 7.]
  [1. 7. 0. 4.]]
 [[5. 8. 9. 5.]
  [4. 7. 7. 9.]
  [6. 9. 2. 6.]]]