Sort words in file

I’ve got some problems I’m not capable of overcoming. I need to count the first let’s say N words in a text file. Then, I have to print them in decreasing order, followed by the number of occurrences….