I have a struct MyType
that contain
int a;
int b;
and I have a vector of that type my_vec
I need to do a custom sort to sort the vector according to a
what's the best way to do that?
I have a struct MyType
that contain
int a;
int b;
and I have a vector of that type my_vec
I need to do a custom sort to sort the vector according to a
what's the best way to do that?
Try this:
std::sort(my_vec.begin(), my_vec.end(), [](const MyType& t1, const MyType& t2) { return t1->a< t2->a; });