MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __lt__

Method __lt__

geometry/graham_scan.py:65–78  ·  view source on GitHub ↗

Compare two points for sorting (bottom-most, then left-most). >>> Point(1, 2) < Point(1, 3) True >>> Point(1, 2) < Point(2, 2) True >>> Point(2, 2) < Point(1, 2) False

(self, other: Point)

Source from the content-addressed store, hash-verified

63 return self.x == other.x and self.y == other.y
64
65 def __lt__(self, other: Point) -> bool:
66 """
67 Compare two points for sorting (bottom-most, then left-most).
68
69 >>> Point(1, 2) < Point(1, 3)
70 True
71 >>> Point(1, 2) < Point(2, 2)
72 True
73 >>> Point(2, 2) < Point(1, 2)
74 False
75 """
76 if self.y == other.y:
77 return self.x < other.x
78 return self.y < other.y
79
80 def euclidean_distance(self, other: Point) -> float:
81 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected