On Wed, 21 Jan 2009 23:02:11 -0800, koranthala wrote:
Hi,
Dictionary has the items method which returns the value as a list
of tuples.
I was wondering whether it would be a good idea to have an extra
parameter - sort - to allow the tuples to be sorted as the desire of
users.
Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
That is better written as:
l = sorted(abcd.items(), key=lambda x:(x[1].lower(), x[0]))
In Python 2.x, I prefer the style
l = sorted(abcd.iteritems(), key=lambda (k,v): (v.lower(), k))
but Python 3.0 breaks the tuple unpacking per
On Jan 22, 2:53 am, Paul Rubin http://phr...@nospam.invalid wrote:
Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
That is better written as:
l = sorted(abcd.items(), key=lambda x:(x[1].lower(), x[0]))
In Python 2.x, I prefer the style
l = sorted(abcd.iteritems(),
koranthala wrote:
Hi,
Dictionary has the items method which returns the value as a list
of tuples.
I was wondering whether it would be a good idea to have an extra
parameter - sort - to allow the tuples to be sorted as the desire of
users.
Currently what I do is:
class SDict(dict):