Module: Associative arrays: map


Problem

3/9

Sorted Lists #2

Theory Click to read/hide

There is no simple solution to sort by value, so you have to make a vector of pairs from a dictionary, and sort it using a comparator.

Problem

Build an alphabetic-frequency dictionary sorted by word frequency: a list of words, to the right of each word should indicate how many times it occurs in the source file in descending order. If the number of words is the same, the sort is word by word in lexicographic order. The sign of the end of the text is "END!". 
 
Input Output
one
two
three
one
two
two 2
one 2
three 1