vt::sort#

template<typename T, size_t N>
Tensor<T, N> vt::sort(const Tensor<T, N> &tensor, bool copy = true)#

Sort the tensor.

Template Parameters:
  • T – Data type of the tensor.

  • N – Number of dimensions of the tensor.

Parameters:
  • tensor – The tensor object.

  • copy – If True, the input tensor is copied before sorting.

Returns:

Tensor<T, N>: The sorted tensor object.

template<typename T, size_t N>
Tensor<T, N> vt::sort(const Tensor<T, N> &tensor, int axis)#

Sort the tensor along the given axis. The method swaps the axis to the last dimension, and performs a for loop to sort along the last axis. Current implementation is not optimized. The performance could improve if we sort the tensor along the given axis in parallel.

Template Parameters:
  • T – Data type of the tensor.

  • N – Number of dimensions of the tensor.

Parameters:
  • tensor – The tensor object.

  • axis – The axis to sort.

Returns:

Tensor<T, N>: The sorted tensor object.