I have
vector> vec
in my c++ app.
Every vector of integers as an element of \"big\" vector has 4 INT valu
#include
#include
#include
#include
using namespace std;
// This makes the sort be according to column 2 and ascending
bool sortFunc( const vector& p1,
const vector& p2 ) {
return p1[1] < p2[1];
}
int main() {
srand(time(NULL));
// Creates and initializes 10 x 4 vector
vector< vector > vec;
for( int i=0; i<10; i++ ) {
vector tmpVec;
for( int j=0; j<2; j++ ) {
tmpVec.push_back( rand()%10 );
}
vec.push_back( tmpVec );
}
// Print out the pre-sorted vector
cout << "Pre-sorting state:" << endl;
for( int i=0; i
source: https://shihho.wordpress.com/2012/11/28/sort_with_vectors/