Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10753 > unrolled thread

how to sort a hash list without generating a new object?

Started bysmith jack <thinke365@gmail.com>
First post2011-08-03 02:02 +0800
Last post2011-08-03 02:02 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  how to sort a hash list without generating a new object? smith jack <thinke365@gmail.com> - 2011-08-03 02:02 +0800

#10753 — how to sort a hash list without generating a new object?

Fromsmith jack <thinke365@gmail.com>
Date2011-08-03 02:02 +0800
Subjecthow to sort a hash list without generating a new object?
Message-ID<mailman.1795.1312308133.1164.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web