Sorting datetime objects while ignoring the year?

datetime, python, sorting

Solution

You can use `month` and `day` to create a value that can be used for sorting:

birthdays.sort(key = lambda d: (d.month, d.day))

Problem

I have a list of birthdays stored in `datetime` objects. How would one go about sorting these in Python using only the `month` and `day` arguments? For example, ``` [ datetime.datetime(1983, 1, 1, 0, 0) datetime.datetime(1996, 1, 13, 0 ,0) datetime.datetime(1976, 2, 6, 0, 0) ... ] ``` Thanks! :)

Original source