Sort Eigen matrix column values by ascending order of column 1 values
<p>I have a n x 3 matrix in Eigen. I would like to rearrange the values of the 2nd and 3rd columns by sorting the values in the 1st column in ascending order.
E.g before sorting:</p>

<pre><code>  1  4  6
 -2  5  2
  3  1  0
</code></pre>

<p>After sorting according to ascending order of column 1 values:</p>

<pre><code> -2 5 2
  1 4 6
  3 1 0
</code></pre>

<p>I am at a loss at how to approach this. I could read each column into a vector and sort the column 1 vector using std::sort but I fail to see how I can retain the corresponding values in columns 2 and 3 for the sorted values in column 1. The value of n is known and is fixed, if that helps in any way.</p>