in reply to How do I create a list with the 10 most frequently used words in a file?

this program shows the frequency of every word in the appeared order of the text file
No, it doesn't. It's sorting the keywords alphabetically. It's eqivalent to
sort { $a cmp $b } keys %count
To sort by count use this sort block
sort { $count{$a} <=> $count{$b} } keys %count
For descending order reverse the sort operands
sort { $count{$b} <=> $count{$a} } keys %count


holli

You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re^2: How do I create a list with the 10 most frequently used words in a file?
by Jannejannesson (Novice) on Apr 29, 2019 at 15:32 UTC

    You are correct, that's my bad, I was a bit stressed when I wrote this. I'll make sure to be clearer in any eventual posts.