std::list 自定义排序

struct cmp  
{  
bool operator () (const string& a,const string& b)  
{  
return a.size() < b.size();  
}
};  

int _tmain(int argc, _TCHAR* argv[])
{
std::list list_story;

list_story.push_back("the");
list_story.push_back("quick");
list_story.push_back("red");
list_story.push_back("fox");
list_story.push_back("jumps");
list_story.push_back("over");
list_story.push_back("the");
list_story.push_back("slow");
list_story.push_back("red");
list_story.push_back("turtle");

list_story.sort(cmp());

return 0;
}


你可能感兴趣的:(c++,list,string,struct)