On 10 Jun 2013 10:53, "Νικόλαος Κούρας" <nikos.gr...@gmail.com> wrote: > > After many tried this did the job: > > for key in sorted(months.items(),key=lambda num : num[1]): > print(''' > <option value="%s"> %s </option> > ''' % (key[1], key[0]) ) > > > but its really frustrating not being able to: > > for key in sorted( months.values() ): > print(''' > <option value="%s"> %s </option> > ''' % (months[key], key) ) > > Which seemed to be an abivous way to do it. > names set() was able to order like this why not the dictionary too?
Why not for key, value in sorted(d.items()): Tuples are totally sortable.
-- http://mail.python.org/mailman/listinfo/python-list