16 August 2010

Python sort() method


  alist.sort()            ## correct
  alist = blist.sort()    ## NO incorrect, sort() returns None

The above is a very common misunderstanding with sort() - It DOES NOT return the sorted list. It returns None.

No comments: