I need an O(n log n) algorithm to remove repeated elements from a list. I know that I can use a set, for example but I need an algorithm of this specific complexity and I have no idea how to code it. Since I now have this code, but I don't know what is its complexity although I believe it is not n log n.
def removing(a):
for e in a:
if e in a[a.index(e)+1:]:
a.remove(e)
return a
The exercise says it wants an O(n*log(n)) algorithm, and says nothing about sorting the list before.