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// C++ program to sort a vector in non-decreasing
2// order.
3#include <bits/stdc++.h> // Vector
4#include <algorithm> // Sort
5using namespace std;
6
7int main()
8{
9// Initalizing the vector v with these values
10 vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
11// Vector is sorted in ascending order
12 sort(v.begin(), v.end());
13
14 return 0;
15}