From 0f03a05207b8988b10eb4545ff8821b4a54ca13a Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sun, 10 Nov 2019 14:00:59 +0530 Subject: [PATCH] Sort applicable candidates before computing best candidate --- src/pip/_internal/index/package_finder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/index/package_finder.py b/src/pip/_internal/index/package_finder.py index 9b338e693..74e3299d6 100644 --- a/src/pip/_internal/index/package_finder.py +++ b/src/pip/_internal/index/package_finder.py @@ -473,12 +473,14 @@ class CandidateEvaluator(object): c for c in candidates if str(c.version) in versions ] - return filter_unallowed_hashes( + filtered_applicable_candidates = filter_unallowed_hashes( candidates=applicable_candidates, hashes=self._hashes, project_name=self._project_name, ) + return sorted(filtered_applicable_candidates, key=self._sort_key) + def _sort_key(self, candidate): # type: (InstallationCandidate) -> CandidateSortingKey """