""" Given a list of objects with date_time attributes that return a datetime, this sorts them in ascending order. It requires the dateutil package from http://cheeseshop.python.org/pypi/python-dateutil""" from dateutil.relativedelta import * shows.sort(cmp=lambda x,y:relativedelta(x.date_time,y.date_time).minutes)