def dt_windows_intersect(dt1start, dt1end, dt2start, dt2end):
    """Returns true if two ranges intersect. Note that if two
    ranges are adjacent, they do not intersect.
    Code based on:
    http://beautifulisbetterthanugly.com/posts/2009/oct/7/datetime-intersection-python/
    http://stackoverflow.com/questions/143552/comparing-date-ranges  
    """
if dt2end <= dt1start or dt2start >= dt1end:
    return False
return dt1start <= dt2end and dt1end >= dt2start
Is there a standard Python data structure that keeps thing in sorted order?