From 40886d7d1f3286a5cd1a2f1d499efcdd7f643451 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sun, 3 Feb 2019 15:58:14 -0800 Subject: [PATCH] Fixed error in hole sorting algorithm when some locations have identical distances --- src/Mod/Path/PathScripts/PathUtils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathUtils.py b/src/Mod/Path/PathScripts/PathUtils.py index 8f96f47a9e..690a435c78 100644 --- a/src/Mod/Path/PathScripts/PathUtils.py +++ b/src/Mod/Path/PathScripts/PathUtils.py @@ -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