#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
void biggies(vector<string> &words, vector<string>::size_type sz);
int main()
{
vector<string> svec{ "welcom", "to", "beijing", "china", "welcom", "to",
"hefei", "china" };
biggies(svec, 3);
return 0;
}
void biggies(vector<string> &words, vector<string>::size_type sz)
{
sort(words.begin(), words.end());
stable_sort(words.begin(), words.end(),[sz](const string &a){ return a.size() >sz; });
}
stable_sort的最后一个参数是comp,它需要符合以下格式的函数
bool cmp(const Type1 &a, const Type2 &b);
的要求看上去是要做filter。用copy_if
vector<string> vo;
copy_if(words.begin(), words.end(), std::back_inserter(vo), [sz](const string &a){ return a.size() >sz; });