I have a file containing a list of words, e.g.
carrot apple pen ukulele pen cinnamon carrot carrot
How do I sort this file so that the words which appear the most in it go to the top, and duplicates are removed?
e.g. I'd like
list.txt to contain this after sorting:
carrot pen apple cinnamon ukulele