Skip to content

Commit

Permalink
check key when sorting Neighbors if distance is equal
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-spike committed Oct 11, 2024
1 parent b413ea2 commit 2381d9a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/aerospike_vector_search/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,36 @@ def __lt__(self, other) -> bool:
if not isinstance(other, Neighbor):
return NotImplemented

if self.distance == other.distance:
return self.key.key < other.key.key

return self.distance < other.distance

def __le__(self, other) -> bool:
if not isinstance(other, Neighbor):
return NotImplemented

if self.distance == other.distance:
return self.key.key <= other.key.key

return self.distance <= other.distance

def __gt__(self, other) -> bool:
if not isinstance(other, Neighbor):
return NotImplemented

if self.distance == other.distance:
return self.key.key > other.key.key

return self.distance > other.distance

def __ge__(self, other) -> bool:
if not isinstance(other, Neighbor):
return NotImplemented

if self.distance == other.distance:
return self.key.key >= other.key.key

return self.distance >= other.distance


Expand Down

0 comments on commit 2381d9a

Please sign in to comment.