Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
//get first column
cv::Mat one = your_mat.col(0);
// sort the first column and save indices in dst
cv::Mat1i idx;
cv::sortIdx(one, idx, cv::SORT_EVERY_COLUMN + cv::SORT_ASCENDING);
// now build your final matrix
cv::Mat result(your_mat.rows, your_mat.cols, your_mat.type());
for(int y = 0; y < your_mat.rows; y++){
   your_mat.row(idx(0,y)).copyTo(result.row(y)); //correction here
}