From the cv::sortIdx() documentation:
Instead of reordering the elements themselves, it stores the indices of the sorted elements in the output array.
This means that you will need to call cv::sort() to sort the elements themselves after calling cv::sortIdx() to replicate the behavior of the Matlab sort() function:
cv::Mat source = cv::Mat::eye(3,3,CV_32F), dst; cv::sortIdx(source, dst, CV_SORT_EVERY_ROW + CV_SORT_ASCENDING); cv::sort(source, source, CV_SORT_EVERY_ROW + CV_SORT_ASCENDING);
Now dst contains the transposed indexes, and source contains the sorted data itself.
source share