#include <vector>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
int main()
{
std::vector< std::vector<int> > my_array = { { 3, 8, 7, 2 }, { 9, 12, 0, 4 }, { 12, 2, 14, 1 } } ;
std::sort( std::begin(my_array), std::end(my_array),
[]( const std::vector<int>& a, const std::vector<int>& b ) { return a[1] < b[1] ; } ) ;
for( const auto& row : my_array )
{
for( int v : row ) std::cout << std::setw(3) << v ;
std::cout << '\n' ;
}
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGl0ZXJhdG9yPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxpb21hbmlwPgoKaW50IG1haW4oKQp7CiAgICBzdGQ6OnZlY3Rvcjwgc3RkOjp2ZWN0b3I8aW50PiA+IG15X2FycmF5ID0geyB7IDMsIDgsIDcsIDIgfSwgeyA5LCAxMiwgMCwgNCB9LCB7IDEyLCAyLCAxNCwgMSB9IH0gOwoKICAgIHN0ZDo6c29ydCggc3RkOjpiZWdpbihteV9hcnJheSksIHN0ZDo6ZW5kKG15X2FycmF5KSwKICAgICAgICAgICAgICAgW10oIGNvbnN0IHN0ZDo6dmVjdG9yPGludD4mIGEsIGNvbnN0IHN0ZDo6dmVjdG9yPGludD4mIGIgKSB7IHJldHVybiBhWzFdIDwgYlsxXSA7IH0gKSA7CgogICAgZm9yKCBjb25zdCBhdXRvJiByb3cgOiBteV9hcnJheSApCiAgICB7CiAgICAgICAgZm9yKCBpbnQgdiA6IHJvdyApIHN0ZDo6Y291dCA8PCBzdGQ6OnNldHcoMykgPDwgdiA7CiAgICAgICAgc3RkOjpjb3V0IDw8ICdcbicgOwogICAgfQp9Cg==