struct compare
{
bool operator()(const pair<string,int>&p1,const pair<string,int>&p2)
{
return p1.second>p2.second;//second为value ,从大到小的顺序
}
}
struct compare1
{
bool operator()(const pair<string,int>&p1,const pair<string,int>&p2)
{
return p1.second<p2.second;//second为value ,从小到大的顺序
}
}
//排序
sort(vec.begin(),vec.end(),compare());//调用自己的比较器函数
struct CMP
{
public:
bool operator() (const int a,const int b)
{
if(a>b)
{
return true; // 从大到小
}else
{
return false;
}
}
};
bool CMP1 (const int a,const int b)
{
if(a<b)
{
return true; // 从小到大
}else
{
return false;
}
}