如果代码如下
1 struct person 2 { 3 string name; 4 int age; 5 }; 6 list<person> example;
如果想按照person.age排序如何使用sort()呢
代码如下:
struct test { bool operator()(person& a, person& b)const { return(a.age > b.age); } }; example.sort(test());
将test里面重载()作为list排序规则
end