C++帮助STL - sort()函数

gau*_*inc 2 c++ sorting algorithm stl

关于STL的另一个小问题:

我有词典:

map <string,vector <Wordy> > Dictionary;
Run Code Online (Sandbox Code Playgroud)

使用结构Wordy:

struct Wordy{ int count; string word;}
Run Code Online (Sandbox Code Playgroud)

这个结构也有重载运算符<

bool operator< (Wordy& One, Wordy& Two){return One.count<Two.count;}
Run Code Online (Sandbox Code Playgroud)

但是算法中的这个sort()函数不起作用!

sort(Dictionary.find(s)->second.begin(),Dictionary.find(s)->second.end());
Run Code Online (Sandbox Code Playgroud)

Xeo*_*Xeo 8

operator<应该通过引用到const来获取它的参数,我想可能是这样的:

bool operator< (const Wordy& One, const Wordy& Two){return One.count<Two.count;}
//              ^^^^^             ^^^^^
Run Code Online (Sandbox Code Playgroud)