Fixed error in hole sorting algorithm when some locations have identical distances

This commit is contained in:
Markus Lampert
2019-02-03 15:58:14 -08:00
committed by Yorik van Havre
parent c0b3e0d4e4
commit 40886d7d1f

View File

@@ -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