MCPcopy Create free account
hub / github.com/ActiveState/code / add

Method add

recipes/Python/52231_Count_items_sort/recipe-52231.py:4–6  ·  view source on GitHub ↗
(self,item)

Source from the content-addressed store, hash-verified

2 def __init__(self):
3 self.dict = {}
4 def add(self,item):
5 count = self.dict.setdefault(item,0)
6 self.dict[item] = count + 1
7 def counts(self,desc=None):
8 '''Returns list of keys, sorted by values.
9 Feed a 1 if you want a descending sort.'''

Callers 5

recipe-520593.pyFile · 0.45
recipe-52231.pyFile · 0.45
recipe-526619.pyFile · 0.45
recipe-521881.pyFile · 0.45
keysMethod · 0.45

Calls 1

setdefaultMethod · 0.45

Tested by

no test coverage detected