How do we remove duplicates from an iterator and put it in sorted order?
Sample input:
it = iter(["black", "aqua", "aqua", "black", "black", "blue", "aqua", "blue", "fuchsia", "gray", "gray", "green", "green", "aqua", "lime", "lime"])
Expected output:
it = iter(["aqua", "black", "blue", "fuchsia", "gray", "green", "lime",])
Similar questions have been asked before:
someone previously asked how to remove duplicates from an iterator about implementing the iterator protocol and their own class with
__iter__
and__next__
methods defined.someone previously asked how to remove duplicates from an iterator restricted to not using Python's built-in
set
class.
There are almost no restrictions on this question other than it be written in Python.