Problem in sorting string when salary same (Sort Game question)


i am getting error while sorting strings when salary is same.
Where am i getting it wrong??

Hi @anishmittal

Strcpy is used to copy character array. In case of strings you can directly use assignment operator. Like temp = v[i+1].first.

Hope it Helps.

Also, if two strings have same money then we have to display them lexicographically, Hence your comparator function will be modified to :
if(p1.second==p2.second)
return p1.first<p2.first;
return p1.second > p2.second;

Hope it Helps.