#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' ;
    }
}
