I am trying to sort a vector of pairs but I am not able to understand what is error in this code.
#include <bits/stdc++.h>
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {
return (a.second < b.second);
}
using namespace std;
int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
long int t, i;
cin >> t;
vector<pair<int, int>> vect;
pair<int, int> tmp;
for (i = 0; i < t; i++) {
cin >> tmp.first;
vect.push_back(tmp);
}
sort(vect.begin(), vect.end(), sortbysec);
return 0;
}
Someone please help me to understand what is wrong in this piece of code.