how to sort a hash list without generating a new object?
smith jack
thinke365 at gmail.com
Tue Aug 2 14:02:09 EDT 2011
the source code is as follows
x={}
x['a'] = 11
x['c'] = 19
x['b'] = 13
print x
tmp = sorted(x.items(), key = lambda x:x[0]) # increase order by
default, if i want to have a descending order, what should i do?
# after sorted is called, a list will be generated, and the hash list
x is not changed at all, how to convert x to a sorted hash list
without generating a new object?
print tmp
print x
More information about the Python-list
mailing list