Learn R Programming

torch (version 0.0.2)

torch_sort: Sort

Description

Sort

Arguments

input

(Tensor) the input tensor.

dim

(int, optional) the dimension to sort along

descending

(bool, optional) controls the sorting order (ascending or descending)

out

(tuple, optional) the output tuple of (Tensor, LongTensor) that can be optionally given to be used as output buffers

sort(input, dim=-1, descending=False, out=None) -> (Tensor, LongTensor)

Sorts the elements of the input tensor along a given dimension in ascending order by value.

If dim is not given, the last dimension of the input is chosen.

If descending is True then the elements are sorted in descending order by value.

A namedtuple of (values, indices) is returned, where the values are the sorted values and indices are the indices of the elements in the original input tensor.

Examples

Run this code
# NOT RUN {
if (torch_is_installed()) {

x = torch_randn(c(3, 4))
out = torch_sort(x)
out
out = torch_sort(x, 1)
out
}
# }

Run the code above in your browser using DataLab