1 struct temp{ int __iValue; int __iKey; };
2 temp __Stru1 = { 100,100};
3 temp __Stru2 = { 2,-10 };
4 temp __Stru3 = { 200,1 };
5 temp __Stru4 = { 600,2 };
6
7 std::list<temp*> test_list;
8 test_list.push_back(&__Stru1);
9 test_list.push_back(&__Stru2);
10 test_list.push_back(&__Stru3);
11 test_list.push_back(&__Stru4);
12 test_list.sort([](std::list<temp*>::value_type& item,std::list<temp*>::value_type& item2 )->bool{ return item->__iKey > item2->__iKey; } );
13
14 std::for_each(test_list.begin(), test_list.end(), [](std::list<temp*>::value_type& item)
15 {
16 std::cout << item->__iValue << std::endl;
17 });