vector<pair<int, int> >の第一要素を昇順、第二要素を降順にしたりするメモ

昨日今日でだいぶはまったので、

AOJ2400から



bool cmp(const pair<int, int> &a, const pair<int, int> &b){
    if(a.first != b.first) return a.first < b.first;
    else return a.second > b.second;
}
typedef pair<int, pair<int, int> > tpair;

bool cmp(const tpair &a, const tpair &b){
  if(a.second.first != b.second.first) return a.second.first > b.second.first;
  else if(a.second.second != b.second.second) return a.second.second < b.second.second;
  else return a.first < b.first;
}
  sort(data.begin(), data.end(), cmp);
}

第一要素を昇順に第二要素を降順にして、ソートします。
コンパイルすらしてないので動くか分かりませんが、2つ目が問題のコードです。
@gasin_satoさんのアドバイスと、@kyos1704さんが偶然、ツイートしていたコードを拝借しました。