mindate = datetime.date(datetime.MINYEAR, 1, 1)

def getaccountingdate(x):
    return x['accountingdate'] or mindate
results = sorted(results, key=getaccountingdate, reverse=True)
In python, sorting on date field, field may sometimes be null