'Sort Eigen Matrix rows *in place* by elements in first column

I am trying to sort Eigen::matrix rows by their value in their first column using ideally std::sort and in place if possible as I'm working with large data set.

MatrixXd input  = [9,2,3,
                   2,99,6,
                   5,2,9]
MatrixXd output = [2,99,6,
                   5,2,9,
                   9,2,3]

I'm assuming i will need to implement a custom solution as std::sort requires an iterator.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source