This can be a solution!
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool compare(const vector<string> &V1, const vector<string> &V2) {
return V1[1] < V2[1];
}
int main(void) {
vector< vector<string> > container;
sort(container.begin(), container.end(), compare);
return 0;
}
Edit
I would like to mention an alternative way in case of you don't know that(Remember, std::sort
is about 670% faster than std::qsort
due to the fact of inline. So this isn't better than above) :
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int compare(const void* a, const void* b) {
vector<string> V1 = *((vector<string>*)a);
vector<string> V2 = *((vector<string>*)b);
if (V1[1] > V2[1])
return -1;
if (V1[1] == V2[1])
return 0;
return 1;
}
int main(void) {
vector< vector<string> > container;
qsort(&container[0], container.size(), sizeof(string), compare);
return 0;
}