Fix Python – How to sort Counter by value? – python

Other than doing list comprehensions of reversed list comprehension, is there a pythonic way to sort Counter by value? If so, it is faster than this:
>>> from collections import Counter
>>> x = Counter({‘a’:5, ‘b’:3, ‘c’:7})
>>> sorted(x)
[‘a’, ‘b’, ‘c’]
>>> sorted(x.items())
[(‘a’, 5), (‘b’, 3), (‘c’, 7)]
>>> [(l,k) for k,l in sorted([(j,i) for i….

Fix Python – defaultdict of defaultdict?

Is there a way to have a defaultdict(defaultdict(int)) in order to make the following code work?
for x in stuff:
d[x.a][x.b] += x.c_int

d needs to be built ad-hoc, depending on x.a and x.b elements.
I could use:
for x in stuff:
d[x.a,x.b] += x.c_int

but then I wouldn’t be able to use: