Advertisement
Vultraz

Untitled

Aug 27th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1.     std::sort(users_sorted_.begin(), users_sorted_.end(), [by_name, by_relation](const user_info* u1, const user_info* u2) {
  2.         return
  3.             (by_name     ? u1->name < u2->name : true) &&
  4.             (by_relation ? static_cast<int>(u1->relation) < static_cast<int>(u2->relation) : true);
  5.     });
  6.  
  7.     if(by_name && by_relation) {
  8.         std::sort(users_sorted_.begin(), users_sorted_.end(), [](const user_info* u1, const user_info* u2) {
  9.             return static_cast<int>(u1.relation) < static_cast<int>(u2.relation) || (u1.relation == u2.relation && u1.name < u2.name)
  10.         });
  11.     } else if(by_name && !by_relation) {
  12.         std::sort(users_sorted_.begin(), users_sorted_.end(), [](const user_info* u1, const user_info* u2) {
  13.             return u1.name < u2.name;
  14.         });
  15.     } else if(by_relation) {
  16.         std::sort(users_sorted_.begin(), users_sorted_.end(), [](const user_info* u1, const user_info* u2) {
  17.             return static_cast<int>(u1.relation) < static_cast<int>(u2.relation);
  18.         });
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement