[BangPypers] sort query

Dhananjay Nene dhananjay.nene at gmail.com
Sat Oct 24 13:29:14 CEST 2009


On Sat, Oct 24, 2009 at 4:49 PM, bhaskar jain <bhaskar.jain2002 at gmail.com>wrote:

> Thanks all for replying.
>
> Let me be clear,
>
> [..snip..]
>
>
> Now if we have, d = {'a':1, 'b':2}
> >>> l = d.keys().sort()
> >>> print l
> None
>
>
> d.keys() is a list  which references the keys of the dictionary.
> But the sort method does not do what is intended on this list?
>

Whoa..

x=d.keys()
x.sort()

ends up sorting the list in place. It does EXACTLY what it is documented as
doing. ie. sort the list in place and return None.
So whats the basis of  "sort method does not do what is intended on this
list" ?


> --Bhaskar.
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--------------------------------------------------------
blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene http://twitter.com/_pythonic


More information about the BangPypers mailing list