SyntaxFix
Write A Post
Hire A Developer
Questions
More general sorted, where the key keyword defines the sorting method, minus before numerical type indicates descending:
key
>>> x = Counter({'a':5, 'b':3, 'c':7}) >>> sorted(x.items(), key=lambda k: -k[1]) # Ascending [('c', 7), ('a', 5), ('b', 3)]