Sorting dict by value w/ operator.itemgetter- using key name?

Wells Oliver wells at submute.net
Thu Jul 30 14:45:53 EDT 2009


Bit of code:

print sorted(results.items(), key=operator.itemgetter(1))

Would rather use 'H9', which is the name of the key in position 1 like:

print sorted(results.items(), key=operator.itemgetter('H9'))

Obviously that ain't work else I wouldn't be sending this email. Any tips?

-- 
Wells Oliver
wells at submute.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090730/7236657b/attachment.html>


More information about the Python-list mailing list