ok, so how do I return a sorted list without doing it in place
Kalle Svensson
kalle at gnupung.net
Fri Feb 16 19:56:17 EST 2001
Sez Sean 'Shaleh' Perry:
> 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])
>
> ???
# Courtesy of Alex Martelli, a few dozen posts earlier or so.
def sort(l):
l.sort()
return l
for key in sort(dict.keys()):
print "%s -> %s" % (key, dict[key])
That's the best you can get, methinks.
Peace,
Kalle
--
Email: kalle at gnupung.net | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20010217/cb5416ac/attachment.sig>
More information about the Python-list
mailing list