目前正在执行以下操作:
import collections
dict = {'alex1':'thing1','alex2':'thing2','alex11':'thingy','adam1':'foo','adam3':'bar','adam22':'drew'}
od = collections.OrderedDict(sorted(dict.items()))
for key,val in od.items():
print key
获得以下
adam1
adam22
adam3
alex1
alex11
alex2
哪个已排序,但我希望它是:
adam1
adam3
adam22
alex1
alex2
alex11
它既是字母顺序又是数字顺序。我怎样才能做到这一点?