11 lines
318 B
Python
11 lines
318 B
Python
from collections.abc import Callable, Iterable
|
|
from typing import Any
|
|
|
|
|
|
def stable_unique(values: Iterable[Any], key: Callable[[Any], Any]) -> list[Any]:
|
|
result = []
|
|
for value in values:
|
|
if not any(key(existing) == key(value) for existing in result):
|
|
result.append(value)
|
|
return result
|