vincent wehren wrote:
> "Volker Grabsch" <[EMAIL PROTECTED]> schrieb im 
> Newsbeitrag news:[EMAIL PROTECTED]
> | However, I don't want to sort them the default way. These are birthdays,
> | so only the month and day do matter, not the year. E.g.:
> |
...
> If you don't care about the year, why not just "normalize" the year
> to all be the same using the replace method of the date instance?
> Something like:
> 
> d1 = datetime.date(2004, 12, 2)
> d2 = datetime.date(2001, 12, 3)
> d3 = datetime.date(2002, 12, 6)
> d4 = datetime.date(1977, 12, 7)
> dates =[d1,d2,d3,d4]
> datesNorm = [obj.replace(year=1900) for obj in (dates)]
> datesNorm.sort()
> print datesNorm # etcetera

Or just use the .timetuple() method on datetime objects and sort on the 
8th element of the 9-element tuple, which is the day-of-the-year.

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to