def dedup(seq):
    """Remove duplicates. Preserve order first seen.  Assume orderable, but not hashable elements"""
result = []
seen = []
for x in seq:
    i = bisect_left(seen, x)
if i == len(seen) or seen[i] != x:
    seen.insert(i, x)
result.append(x)
return result
Removing duplicate elements from a Python list containing unhashable elements while preserving order?