diff --git a/conda_lock/lockfile/v2prelim/models.py b/conda_lock/lockfile/v2prelim/models.py index dffafe142..e322c803c 100644 --- a/conda_lock/lockfile/v2prelim/models.py +++ b/conda_lock/lockfile/v2prelim/models.py @@ -71,7 +71,14 @@ def toposort_inplace(self) -> None: self.package = self._toposort(self.package) def alphasort_inplace(self) -> None: + # Sort the packages themselves by key (conda/pip, name, platform) self.package.sort(key=lambda d: d.key()) + for p in self.package: + # Also ensure that the dependencies of each package are sorted + # + p.dependencies = { + name: spec for name, spec in sorted(p.dependencies.items()) + } def filter_virtual_packages_inplace(self) -> None: self.package = [