Problem

5 /9


Lists: alphabetical-frequency dictionary

Problem

Given a text that consists of several lines. The text ends with a line containing the single word "END!". The word "END!" is not the content of the text, but only serves as a sign of the end.

Build for the given text an alphabetic-frequency dictionary sorted by the frequency of words: a list of words, to the right of each word should be indicated how many times it occurs in the source file. The words must be in descending order. If the number of words is the same, the sort is word by word in lexicographic order.

Words should be lowercase, and without punctuation marks.
 
Example
# Input Output
1 Duis aute irure dolor in reprehenderit in voluptate.
Velit esse cillum dolore eu fugiat nulla pariatur.
END!
in 2
aute 1
cillum 1
dolor 1
dolore 1
duis 1
esse 1
eu1
fugiat 1
irure 1
nulla 1
pariatur 1
reprehenderit 1
velit 1
voluptate 1