Question on sort() key function

Paul Rubin http
Tue Jan 22 08:24:34 EST 2008


Robert Latest <boblatest at yahoo.com> writes:
> >    flist.sort(key=lambda f: f.mod_date.toordinal)
> 
> It doesn't throw an error any more, but neither does it sort the list. This, 
> however, works:

Oh, I didn't realize that toordinal was a callable, given your earlier
sample.  You want:

   flist.sort(key=lambda f: f.mod_date.toordinal() )



More information about the Python-list mailing list