如何在结构体中定义排序规则

struct node
{
	int idx,sum;
	string name;
	friend bool operator < (node a,node b){
		if(a.sum==b.sum){
			return a.idx>b.idx;
		}
		return a.sum<b.sum;
	}

}a[N];
posted @ 2023-11-13 21:47  du463  阅读(7)  评论(0编辑  收藏  举报