def unorderable_list_difference(expected, actual, ignore_duplicate=False):
missing = []<EOL>unexpected = []<EOL>while expected:<EOL><INDENT>item = expected.pop()<EOL>try:<EOL><INDENT>actual.remove(item)<EOL><DEDENT>except ValueError:<EOL><INDENT>missing.append(item)<EOL><DEDENT>if ignore_duplicate:<EOL><INDENT>for lst in expected, actual:<EOL><INDENT>try:<EOL><INDENT>while True:<EOL><INDENT>lst.remove(item)<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if ignore_duplicate:<EOL><INDENT>while actual:<EOL><INDENT>item = actual.pop()<EOL>unexpected.append(item)<EOL>try:<EOL><INDENT>while True:<EOL><INDENT>actual.remove(item)<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return missing, unexpected<EOL><DEDENT>return missing, actual<EOL>
Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.