string, split, sort, None, huh?

Phlip phlip_cpp at
Fri Feb 16 23:42:58 CET 2001

Thy Pon:

Gonna split a document by linefeeds into strings, then sort the strings. 
Child's play, huh?

        lines = split ( """Mary
lamb""", "\n" )

        print repr(lines)
        print repr(lines.sort())

Now the output:

        ['Mary', 'had', 'a', 'little', 'lamb']

So where'd that 'None' come from? The Sorting Mini-HOWTO here said strings 
are just as easy as numbers:

Variations with 'cmp' and 'lambda x, y: cmp(x, y)' also get 'None'.

  Phlip                          phlip_cpp at
============ ============
  --  Proud victim of the dreaded boomerang effect  --

More information about the Python-list mailing list