首页 > 代码库 > sort

sort

sort int

bool cmp(int a,int b)
{
     return a>b;   
}
int main()
{
     int a[100];
     sort(a,a+100,cmp);
}

sort struct

struct T
{ int x,y;
}nod[100];
bool cmp(T a,T b)//先按x从小到大排,相同,再按y从小到大
{ 
return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
sort(nod,nod+n,cmp);//n是长度

 

sort