1struct data{
2 string word;
3 int number;
4};
5
6
7bool my_cmp(const data& a, const data& b)
8{
9 // smallest comes first
10 return a.number < b.number;
11}
12
13std::sort(A.begin(), A.end(), my_cmp);
1
2struct data{
3 string word;
4 int number;
5};
6
7
8bool my_cmp(const data& a, const data& b)
9{
10 // smallest comes first
11 return a.number() < b.number();
12}
13
14std::sort(A.begin(), A.end(), my_cmp);