sort用法
sort基础
#include <algorithm>
sort(first_pointer,first_pointer+n,cmp);
sort升级
bool cmp1(int a,int b)//int为数组数据类型
{
return a>b;//降序排列
//return a<b;//默认的升序排列
}
sort(A,A+100,cmp1);
//情况二:结构体排序
Student Stu[100];
bool cmp2(Student a,Student b)
{
return a.id>b.id;//按照学号降序排列
//return a.id<b.id;//按照学号升序排列
}
sort(Stu,Stu+100,cmp2);
if(G[u][i]!=fa)
{
node.push_back(dfs(G[u][i],u));
}
sort(node.begin(),node.end()); //额,还有这种sort排序