#include <string> #include <list> #include <algorithm> #include <iostream> using namespace std; bool op(string str1, string str2) { return str1.length() < str2.length(); } int main(int argc, char* argv[]) { list <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(op); for(list<string>::iterator i = list_story.begin(); i != list_story.end(); i++) { cout << *i << endl; } }