def sorted_list_difference(expected, actual):
i = j = <NUM_LIT:0><EOL>missing = []<EOL>unexpected = []<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>e = expected[i]<EOL>a = actual[j]<EOL>if e < a:<EOL><INDENT>missing.append(e)<EOL>i += <NUM_LIT:1><EOL>while expected[i] == e:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif e > a:<EOL><INDENT>unexpected.append(a)<EOL>j += <NUM_LIT:1><EOL>while actual[j] == a:<EOL><INDENT>j += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL>try:<EOL><INDENT>while expected[i] == e:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>finally:<EOL><INDENT>j += <NUM_LIT:1><EOL>while actual[j] == a:<EOL><INDENT>j += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT>except IndexError:<EOL><INDENT>missing.extend(expected[i:])<EOL>unexpected.extend(actual[j:])<EOL>break<EOL><DEDENT><DEDENT>return missing, unexpected<EOL>
Finds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.