def special_len(tup):
    """
    comparison function that will sort a document:
    (a) according to the number of segments
    (b) according to its longer segment
    """
    doc = tup[0] if type(tup) is tuple else tup
    return (len(doc), len(max(doc, key=len)))