What is this variable doing here?

What is this variable doing here ?
And should I put ‘word’ there as well ? Rubocop wants me to.

Frequencies is hash that contains keys and values,
In the sort_by block the keys and values are identified as |word, count| you then sort_by count
You have told ruby that you have a hash with words and counts and you would like to sort it by the counts

Ok. But I think that variable should be on the same line as the other code, instead of being by itself.

Thats a matter of style, if you put it on the same line you’d also probably change the do end block into a {} block frequencies.sort_by{|word,count|count}

That looks better and makes more sense.

The ‘do’ keyword is for multi-lines and {} is for single lines.