![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
struct data { int xuhao,w; }node[maxn]; bool cmp(data a,data b) { return a.dis < b.dis; }//°´dis´ÓСµ½´óÅÅÐò
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
sort(node+1,node+1+n,cmp);
结构体排序
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
struct data { int price,number; }a[maxn]; bool cmp(data a,data b) { if(a.price==b.price)return a.number<b.number; else return a.price<b.price; } //原理:若a<b返回1 ab就换位