Sorting of ngram reversed

Changed sort of ngram and generator now chooses a random word of the
three best (if possible)