From 277f05754d409193551576c7d20195850101a963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E5=85=B4=E8=8C=82?= Date: Thu, 7 Sep 2017 14:17:04 +0800 Subject: [PATCH] Add default sort for show --tree option --- src/Composer/Command/ShowCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index e9ffbe029..01f38c92c 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -222,7 +222,9 @@ EOT $io->writeError('Format "json" is only supported for package listings, falling back to format "text"'); } $rootRequires = $this->getRootRequires(); - foreach ($installedRepo->getPackages() as $package) { + $packages = $installedRepo->getPackages(); + usort($packages, 'strcmp'); + foreach ($packages as $package) { if (in_array($package->getName(), $rootRequires, true)) { $this->displayPackageTree($package, $installedRepo, $repos); } @@ -703,6 +705,7 @@ EOT if (is_object($package)) { $requires = $package->getRequires(); + ksort($requires); $treeBar = '├'; $j = 0; $total = count($requires); @@ -744,6 +747,7 @@ EOT list($package, $versions) = $this->getPackage($installedRepo, $distantRepos, $name, $package->getPrettyConstraint() === 'self.version' ? $package->getConstraint() : $package->getPrettyConstraint()); if (is_object($package)) { $requires = $package->getRequires(); + ksort($requires); $treeBar = $previousTreeBar . ' ├'; $i = 0; $total = count($requires);