Steven Bethard <[EMAIL PROTECTED]> writes: > If len() were a method of string objects, you could try using the > unbound method and writing this as:: > > >>> sorted(['aaa', 'bb', 'c'], key=str.len) > ['c', 'bb', 'aaa'] > > But then your code would break on lists that weren't strings.
sorted(['aaa', 'bb', 'c'], key=lambda x: x.len()) -- http://mail.python.org/mailman/listinfo/python-list