def dist(obj1,
         obj2):
    """
    returns the minimum distance from the current object and obj.
    Distance is measured as current start to object end or
    current end to object start
    """
    return min(abs(obj1.span[1] - obj2.span[0]),
               abs(obj1.span[0] - obj2.span[1]))