ok, so how do I return a sorted list without doing it in place

Sean 'Shaleh' Perry shaleh at valinux.com
Fri Feb 16 19:04:10 EST 2001


So, several of us informed Philip that list.sort() is in place and returns
nothing.  How do i accomplish:

for key in dict.keys().sort():
  print "%s -> %s" % (key, dict[key])

???

I know I can do:

list = dict.keys()
list.sort()
.....

but it is just plain annoying.




More information about the Python-list mailing list