c++结构体的排序

出处:https://blog.csdn.net/weixin_39460667/article/details/82695190

 

引入头文件 

#include<algorithm>

结构体

 

bool compare(const node &x, const node &y)

{
return x.v > y.v;
}

  

当用 大于号就是从大到小排序

用小于号就是从小到大排序

 

sort 函数   

sort(branch+1,branch+m+1,compare);

  



posted @ 2019-03-04 23:08  Fzzf1  阅读(1163)  评论(0编辑  收藏  举报