vector 二维排序
struct two_num
{
unsigned int a;
unsigned int b;
}
vector<two_num> data;
data 这样的:
a b
2 4
1 3
6 5
7 5
9 3
1 7
2 3
9 12
2 6
要先按照 a 排序, 在 a排序的基础上 在按b 排序:
a b
1 3
1 7
2 3
2 4
2 6
6 5
7 5
9 3
9 12
[解决办法]
- C/C++ code
bool operator () (const T& _L, const T& _R) {return _L.first < _R.first || _L.first == _R.first ? _L.second < _R.second : false;}
[解决办法]
- C/C++ code
bool operator () (const T& _L, const T& _R) { if(_L.first > _R.first) return 0; if(_L.first == _R.first) return _L.second<_R.second; }