[][src]Function opencv::core::sort_idx

pub fn sort_idx(
    src: &dyn ToInputArray,
    dst: &mut dyn ToOutputArray,
    flags: i32
) -> Result<()>

Sorts each row or each column of a matrix.

The function cv::sortIdx sorts each matrix row or each matrix column in the ascending or descending order. So you should pass two operation flags to get desired behaviour. Instead of reordering the elements themselves, it stores the indices of sorted elements in the output array. For example:

This example is not tested
Mat A = Mat::eye(3,3,CV_32F), B;
sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
// B will probably contain
// (because of equal elements in A some permutations are possible):
// [[1, 2, 0], [0, 2, 1], [0, 1, 2]]

Parameters

  • src: input single-channel array.
  • dst: output integer array of the same size as src.
  • flags: operation flags that could be a combination of cv::SortFlags

See also

sort, randShuffle