good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: How do I create a list with the 10 most frequently used words in a file?by roboticus (Chancellor) |
on Apr 29, 2019 at 15:14 UTC ( [id://1233137]=note: print w/replies, xml ) | Need Help?? |
Getting the "top N" or "bottom N" items of a list is often handled by sorting the keys by frequency of occurrence, and then keeping only the ones you want. You can do it like this:
Note: I didn't test the code, but it should be pretty close. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|