@@ -10,6 +10,10 @@ def __init__(self, a, b, c, d):
10
10
self .d = d
11
11
def __repr__ (self ):
12
12
return 'Point({!r:},{!r:},{!r:},{!r:})' .format (self .a , self .b , self .c , self .d )
13
+ def __lt__ (self , other ):
14
+ return (self .a < other .a if self .a != other .a else (self .b < other .b if self .b != other .b else (self .c < other .c if self .c != other .c else self .d < other .d )))
15
+ def __gt__ (self , other ):
16
+ return (self .a > other .a if self .a != other .a else (self .b > other .b if self .b != other .b else (self .c > other .c if self .c != other .c else self .d > other .d )))
13
17
def distance (self , a , b , c , d ):
14
18
return math .hypot (self .a - a , self .b - b , self .c - c , self .d - d )
15
19
@@ -25,4 +29,6 @@ def distance(self, a, b, c, d):
25
29
Point (1 , - 3 , - 2 , - 1 )
26
30
]
27
31
28
- print (sortingx .heap (points , key = methodcaller ('distance' , 0 , 0 , 0 , 0 )))
32
+ print (sortingx .heap (points , key = methodcaller ('distance' , 0 , 0 , 0 , 0 )))
33
+ # print(sortingx.merge(points))
34
+ # print(sortingx.insert(points, reverse=True))
0 commit comments