std::list 自定义排序

来源:互联网 发布:专业视频配音软件 编辑:程序博客网 时间:2024/05/21 10:57

struct cmp  {  bool operator () (const string& a,const string& b)  {  return a.size() < b.size();  }};  int _tmain(int argc, _TCHAR* argv[]){std::list<std::string> 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;}