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 1740345217
Clarity is better than cleverness.
Home
Notebook
Contact us