Воробьев Сергей Юрьевич 530 StrictSort 1690
Усович Алексей, 530 группа StrictSort 1709
f1from typing import Protocol, TypeVar, Callable, runtime_checkablef1from typing import Protocol, TypeVar, Callable, runtime_checkable
2from collections.abc import MutableSequence, Sized2from collections.abc import MutableSequence, Sized
33
4@runtime_checkable4@runtime_checkable
n5class SupportsLessThan(Protocol):n5class LessThen(Protocol):
66
7    def __lt__(self, other: object) -> bool:7    def __lt__(self, other: object) -> bool:
8        ...8        ...
n9Comparable = TypeVar('Comparable', bound=SupportsLessThan)n9Comparable = TypeVar('Comparable', bound=LessThen)
10Sortable = MutableSequence[Comparable]10Sortable = MutableSequence[Comparable]
1111
n12def defkey(element: Comparable) -> SupportsLessThan:n12def defkey(element: Comparable) -> LessThen:
13    if isinstance(element, Sized):13    if isinstance(element, Sized):
14        return len(element)14        return len(element)
15    return element15    return element
1616
t17def strictsort(seq: Sortable[Comparable], key: Callable[[Comparable], Sut17def strictsort(inp: Sortable[Comparable], key: Callable[[Comparable], Le
>pportsLessThan]=defkey) -> Sortable[Comparable]:>ssThen]=defkey) -> Sortable[Comparable]:
18    tmp = list(seq)18    lst = list(inp)
19    tmp.sort(key=key)19    lst.sort(key=key)
20    seq[:] = tmp20    inp[:] = lst
21    return seq21    return inp
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op