All problems
Word Frequency Ranking
Problem
Return the words in tokens ordered by descending frequency.
Break ties alphabetically by the word itself. Every distinct word appears exactly once, and an empty token list yields an empty list.
Hint
Sort the distinct words by the tuple (negative count, word).
Test cases
case 1
in: [["b","a","b","c"]]
expected: ["b","a","c"]
case 2
in: [["the","cat","sat","on","the","mat"]]
expected: ["the","cat","mat","on","sat"]
case 3
in: [[]]
expected: []
case 4
in: [["a","a","b","b","c"]]
expected: ["a","b","c"]
Starter codePython
def zipf_rank(tokens):
# Your code here
pass4 test cases · run your code against them in the editor