CPP
sort vector c++
//me
vector<int> v{2,5,3,4,0,1};
sort( v.begin(), v.end() );
//v is now {0,1,2,3,4,5}
C++ vector sort
// C++ program to sort a vector in non-decreasing
// order.
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end());
cout << "Sorted
";
for (auto x : v)
cout << x << " ";
return 0;
}
c++ sort vector
// C++ program to sort a vector in non-decreasing
// order.
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end());
return 0;
}
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);
sort a vector c++
sort(a.begin(), a.end());
how to sort vector of struct in c++
struct point{
int weight, position, id;
};
// . . . . . .
// your code
// for sorting using weight
sort(points.begin(), points.end(), [] (point a, point b){
return a.weight < b.weight;
});
// for sorting using positions
sort(points.begin(), points.end(), [] (point a, point b){
return a.position < b.position;
});
sort vector c++
sort(begin(v), end(v), [] (int a, int b) { return a > b; }); // decrease
c++ vector sort
// Initilaize Vector
vector<int> v{10,9,8,7,6,5,4,3,2,1,0};
// Sort Vector
sort(v.begin(), v.end());