Skip to navigation
How order a python dic by key and stay permanent
28.08.14
how to use order a dic by its key and stay permanent #!/usr/bin/env python import os import sys from natsort import natsorted import collections def natsort_keys(self,xdic): keys =natsorted(xdic.keys()) new_dict = collections.OrderedDict() for key in natsorted(keys): new_dict[key] = xdic[key] return new_dict
http://pymotw.com/2/collections/ordereddict.html
Reply
Anonymous
Information Epoch 1736585843
Choose portability over efficiency.
Home
Notebook
Contact us