The Aim: I have a 2d vector. I want to sort it by the value in its 4th column. For example I want to sort this vector:
vector<vector<double>> vector1 = {{4,3,5,3},
{2,6,3,7},
{6,8,5,1},
{5,6,1,5}};
I want to sort its rows by the value in the 4th column, so that its elements position within the rows are unchanged but the rows position within the vector is altered so that the elements in the 4th column are in this order:
vector1 = {{6,8,5,1},
{4,3,5,3},
{5,6,1,5},
{2,6,3,7}};
I am assuming I will have to use sort(), but after searching around online I still honestly have absolutely no idea how to go about this, so any direct help with the code or even directions to websites or resources would be really appreciated. Thanks!