I'm not an advanced Python user, so there may be more efficient or elegant solutions. The code below is a Python 2.5 equivalent. Jamal hash = {'John': 40, 'Michael': 40, 'Joe': 30} keys = sorted(hash.keys(), reverse = True) keys = sorted(keys, lambda x, y: cmp(hash[x], hash[y])) for key in keys: print key + ', ' + str(hash[key]) -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Octavian Rasnita Sent: Wednesday, December 17, 2008 8:40 AM To: programmingblind@xxxxxxxxxxxxx Subject: Re: python question The Windows msi installer for python from python.org contains a chm help file for python 3, or at least this is how it is named. I haven't started to read it though. But I have a question regarding python. I have started to read the book "Perl to python migration" hoping to understand it better, but I am pretty confused of how python does the sorting, or at least about how it is explained in that book that might be old, because it talks about python 2.0. For example, if I have a perl hash, or python dictionary like: my %hash = (Joe => 30, John => 40, Michael => 40); and I want to sort it for example by the values of the hashin increasing order, then by the keys of the hash in decreasing order, in perl I would need to do just: foreach my $key(sort {$hash{$a} <=> $hash{$b} or $b cmp $a} keys %hash) { print "$key, $hash{$key}\n"; } This would print: Joe, 30 Michael, 40 John, 40 Can you tell me how to do this in python? I hope there are newer ways of doing this more easier than what I read in that book. And I would also like to know which is the prefered ORM, the prefered templating systems, form manager(s), web framework... (although I think it is Zope), so if you have used them, please tell me. Octavian ----- Original Message ----- From: <james.homme@xxxxxxxxxxxx> To: <programmingblind@xxxxxxxxxxxxx> Sent: Wednesday, December 17, 2008 2:29 PM Subject: RE: python question > Hi, > Along those lines, does anyone know if any of the Python documentation on > http://www.nonvisualdevelopment.org talks about 3.0? > > Thanks. > > Jim > > James D Homme, Usability Engineering, Highmark Inc., > james.homme@xxxxxxxxxxxx, 412-544-1810 > > "The difference between those who get what they wish for and those who > don't is action. Therefore, every action you take is a complete > success,regardless of the results." -- Jerrold Mundis > Highmark internal only: For usability and accessibility: > http://highwire.highmark.com/sites/iwov/hwt093/ __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind