title: how to find common words between two vectors of std::string
body: <p>I am trying to find common words between 2 vectors of std::string. I want to get those into a sorted list which is sorted by length, and then words of each length to be sorted alphabetically. I need to use stl functions and functors.</p>
  
  <p>My thoughts: 
  using a for_each go through first vector and for each word, compare it to the other vector using a functor (if common, append to a list in functor). Then the resulting list will have only common words in it. Here is where I am stuck, I know how to sort alphabetically, but how do I sort them by length and then sort the same length chunks alphabetically? I have looked around stl, but I am not finding what I need. Or, I am just thinking about this the wrong way. Any ideas?</p>
  
  <p>Example:</p>
  
  <p><strong>vec1:</strong> "and", "thus", "it", "has", "a", "beginning", "and", "end"</p>
  
  <p><strong>vec2:</strong> "and," "therefore", "stars", "are", "beginning", "to","fall","to","their", "end"</p>
  
  <p><strong>result:</strong>  "and", "end", "beginning"</p>