From 3a6602f3fd5f9d15ef876c3972244a8660af4f6f Mon Sep 17 00:00:00 2001 From: Subhan Nadeem Date: Thu, 25 Jul 2019 15:00:38 -0400 Subject: [PATCH] Added proper location sorting instead of filtering to matching algo --- server/matching_algorithm.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/matching_algorithm.js b/server/matching_algorithm.js index 6f77570..9942699 100644 --- a/server/matching_algorithm.js +++ b/server/matching_algorithm.js @@ -9,7 +9,9 @@ function filterConsultantsForProject (project, consultants){ switch(project.priority) { case projects.PRIORITIES.LOCATION: - consultants = consultants.filter(consultant => consultant.locations.includes(project.locations[0])); + consultants = consultants.sort((a,b) => { + return a.locations.includes(project.locations[0]) ? -1 : 1; + }); break; case projects.PRIORITIES.BUDGET: consultants = consultants.sort((a, b) => {