Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::sort(users_sorted_.begin(), users_sorted_.end(), [by_name, by_relation](const user_info* u1, const user_info* u2) {
- return
- (by_name ? u1->name < u2->name : true) &&
- (by_relation ? static_cast<int>(u1->relation) < static_cast<int>(u2->relation) : true);
- });
- if(by_name && by_relation) {
- std::sort(users_sorted_.begin(), users_sorted_.end(), [](const user_info* u1, const user_info* u2) {
- return static_cast<int>(u1.relation) < static_cast<int>(u2.relation) || (u1.relation == u2.relation && u1.name < u2.name)
- });
- } else if(by_name && !by_relation) {
- std::sort(users_sorted_.begin(), users_sorted_.end(), [](const user_info* u1, const user_info* u2) {
- return u1.name < u2.name;
- });
- } else if(by_relation) {
- std::sort(users_sorted_.begin(), users_sorted_.end(), [](const user_info* u1, const user_info* u2) {
- return static_cast<int>(u1.relation) < static_cast<int>(u2.relation);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement