Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void sortrows(std::vector<std::vector<double>>& matrix, vector<int> &columns) {
- int i=columns.size()-1;
- std::sort(matrix.begin(),
- matrix.end(),
- [columns, i](const std::vector<double>& lhs, const std::vector<double>& rhs) {
- int col = columns[i];
- if (lhs[col] == rhs[col])
- {
- if (i>0)
- {
- int second_col = columns[i - 1];
- if (lhs[second_col] == rhs[second_col])
- {
- if (i>1)
- {
- int third_col = columns[i - 2];
- return lhs[third_col] < rhs[third_col];
- }
- }
- return lhs[second_col] < rhs[second_col];
- }
- }
- return lhs[col] < rhs[col];
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement