Return a list or objects sorted by a priority value.

def sort_by_priority(iterable, reverse=False, default_priority=10):
    """
    Return a list or objects sorted by a priority value.
    """
    return sorted(iterable, reverse=reverse, key=lambda o: getattr(o, 'priority', default_priority))