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;
}
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;
}
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;
});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us