Fixed error in hole sorting algorithm when some locations have identical distances
This commit is contained in:
committed by
Yorik van Havre
parent
c0b3e0d4e4
commit
40886d7d1f
@@ -742,10 +742,11 @@ def sort_jobs(locations, keys, attractors=[]):
|
||||
def find_closest(location_list, location, dist):
|
||||
q = PriorityQueue()
|
||||
|
||||
for j in location_list:
|
||||
q.put((dist(j, location) + weight(j), j))
|
||||
for i,j in enumerate(location_list):
|
||||
# prevent dictionary comparison by inserting the index
|
||||
q.put((dist(j, location) + weight(j), i, j))
|
||||
|
||||
prio, result = q.get()
|
||||
prio, i, result = q.get()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user