C ++ 14 implementation of the above approach
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool cmp ( vector < int > a , vector < int > b ) { if ( a [ 0 ] != b [ 0 ] ) return a [ 0 ] < b [ 0 ] ; return a [ 1 ] - b [ 1 ] ; }