Advertisement
Guest User

moja przyśpieszona symulacja #talerz

a guest
Dec 9th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. void sortrows(std::vector<std::vector<double>>& matrix, vector<int> &columns) {
  2.         int i=columns.size()-1;
  3.         std::sort(matrix.begin(),
  4.             matrix.end(),
  5.             [columns, i](const std::vector<double>& lhs, const std::vector<double>& rhs) {
  6.             int col = columns[i];
  7.             if (lhs[col] == rhs[col])
  8.             {
  9.                 if (i>0)
  10.                 {
  11.                     int second_col = columns[i - 1];
  12.                     if (lhs[second_col] == rhs[second_col])
  13.                     {
  14.                         if (i>1)
  15.                         {
  16.                             int third_col = columns[i - 2];
  17.                             return lhs[third_col] < rhs[third_col];
  18.                         }
  19.                     }
  20.                     return lhs[second_col] < rhs[second_col];
  21.                 }
  22.             }
  23.             return lhs[col] < rhs[col];
  24.         });
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement