First I had an int array called Myarray[51][4] filled by data.
For sorting it based on the second column of Myarray, I used the following code (using the conversion of array into a vector of vector: my_vector[51][4]) :
int Myarray [51][4];
vector< vector<int> > my_vector ;
for( const auto& row : Myarray )
my_vector.push_back( vector<int>( begin(row), end(row) ) ) ;
sort( begin(my_vector), end(my_vector),
[]( const vector<int>& a, const vector<int>& b ) { return a[1] < b[1] ; } ) ;
This code has sorted my_vector. Now I want to copy the sorted vector into Myarray again for using it as array of integer with dimension of [51][4]. How do I do it?
int Myarray [51][4]; sort( begin(Myarray), end(Myarray), []( int(&a)[4], int(&b)[4] ) { return a[1] < b[1] ; } ) ;