collection

collection型のソート(Python)

Pythonでcollection型のソートにはOrderedDicを使う。 >>> from collections import OrderedDict >>> # regular unsorted dictionary >>> d = {'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2} >>> # dictionary sorted by key >>> OrderedDict(sorted(d.…