cpp sort vector code example
Example 1: sort vector struct c++
struct data{
string word;
int number;
};
bool my_cmp(const data& a, const data& b)
{
// smallest comes first
return a.number < b.number;
}
std::sort(A.begin(), A.end(), my_cmp);
Example 2: vector sort c++
sort(v.begin(), v.end());
Example 3: sort vector
sort(v.begin(), v.end());
Example 4: sort a vector c++
sort(a.begin(), a.end());