I am having a hard time coming up with a slick way to handle this sort. I have data coming back from a database read. I want to sort on the accoutingdate. However, accoutingdate may sometimes be null. I am currently doing the following:
results = sorted(results, key=operator.itemgetter('accountingdate'), reverse=True)
But, this bombs with "TypeError: can't compare datetime.date to NoneType" due to some accoutingdates being null.
What is the "most correct" or "most Pythonic" way to handle this?