Sort Game STL coding questions problem no 1

//whats wrong with my code

#include<bits/stdc++.h>

using namespace std;

bool comp(pair<string,int> p1,pair<string,int> p2)
{
if(p1.second>p2.second)
{
return p1.second<p2.second;
}
else if(p1.second==p2.second)
{
return p1<p2;
}
}

int main() {
int num,n,d;
cin>>num>>n;
vector<pair<string,int>> vec;
for(int i=0; i<n; i++)
{
string s;
cin>>s>>d;
if(d>num)
vec.push_back(make_pair(s,d));
}
sort(vec.begin(),vec.end(),comp);

for(auto it:vec)
{
	cout<<it.first<<" "<<it.second<<endl;
}
return 0;

}

#include<bits/stdc++.h> using namespace std; bool comp(pair<string,int> p1,pair<string,int> p2) { if(p1.second>p2.second) { return p1.second<p2.second; } else if(p1.second==p2.second) { return p1<p2; } } int main() { int num,n,d; cin>>num>>n; vector<pair<string,int>> vec; for(int i=0; i<n; i++) { string s; cin>>s>>d; if(d>num) vec.push_back(make_pair(s,d)); } sort(vec.begin(),vec.end(),comp); for(auto it:vec) { cout<<it.first<<" "<<it.second<<endl; } return 0; }

Save your code on ide.codingblocks.com and then share its link.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.