OrderedDict
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.…
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.…