Mistake in the program?
@shiva57reddy
First of all do not use getline( ) for input. Use normal cin. getline( ) is giving you some problems with new line character.
Also , you are using two seperate comparator functions which are causing problems. You only need to use one comparator function. You can put two or more criteria in it using if else conditions .
Your program gives wrong output for this input :
Input :
79
6
Eve 78
Bob 99
Suzy 86
Alice 86
Dylan 82
Mark 82
Expected Output :
Bob 99
Alice 86
Suzy 86
Dylan 82
Mark 82
Your Output :
Bob 99
Alice 86
Dylan 82
Mark 82
Suzy 86
@shiva57reddy
This is the first time I have seen such a problem.
Regardless , I would suggest you to use a single comparator function and do sorting only one time
bool mycompare(pair <string,int> a, pair <string,int> b) {
if( a.first == b.first ) {
return a.second > b.second ;
}
return a.first < b.first;
}



