can anyone pls provide me hints for logic ,my logic is to pass acompare function as parameter in inbuilt sort fuction but my compare fuction will take 2 string and 2 number due to which my code is giving error
Sort game Pls help
Hi Ankush, I have seen your code. What you can do is use the pair container of c++.
you create a vector of pairs of type pair< string, int > where pair.first will contain name and pair.second will contain the salary. Now take input and then sort this vector.
In the comparator you will be passing 2 pairss now which you can coompare as:
if ( pair1.second == pair2.second )
return pair1.first > pair2.first
return pair1.second > pair2.second
Also you are missing here 1 condition demanded in the question. See that temp is unused in your code.
Hey Ankush, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.