Матвеев Алексей Дмитриевич, 623 группа StrictSort 1586
Дятлинко Екатерина Сергеевна, 530 группа StrictSort 1542
f1from collections.abc import MutableSequence, Sized, Callablef1from collections.abc import MutableSequence, Sized, Callable
2from typing import Protocol, Any2from typing import Protocol, Any
33
4class Comparable(Protocol):4class Comparable(Protocol):
55
6    def __lt__(self, other: Any) -> bool:6    def __lt__(self, other: Any) -> bool:
7        pass7        pass
8Sortable = MutableSequence[Comparable]8Sortable = MutableSequence[Comparable]
99
10def defkey(element: Comparable) -> Comparable:10def defkey(element: Comparable) -> Comparable:
11    if isinstance(element, Sized):11    if isinstance(element, Sized):
12        return len(element)12        return len(element)
t13    else:t
14        return element13    return element
1514
16def strictsort(seq: Sortable, key: Callable[[Comparable], Comparable]=de15def strictsort(seq: Sortable, key: Callable[[Comparable], Comparable]=de
>fkey) -> Sortable:>fkey) -> Sortable:
17    return sorted(seq, key=key)16    return sorted(seq, key=key)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op