Skip to content

Commit

Permalink
Merge pull request #863 from ergebnis/fix/sort
Browse files Browse the repository at this point in the history
Fix: Sort versions naturally
  • Loading branch information
localheinz authored Feb 27, 2023
2 parents ce0960f + a9d172b commit 0f41f57
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

For a full diff see [`4.0.1...main`][4.0.1...main].

### Fixed

- Adjusted `Vendor\Composer\VersionConstraintNormalizer` to sort versions naturally ([#863]), by [@localheinz]

## [`4.0.1`][4.0.1]

For a full diff see [`4.0.0...4.0.1`][4.0.0...4.0.1].
Expand Down Expand Up @@ -587,6 +591,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0].
[#858]: https://github.com/ergebnis/json-normalizer/pull/858
[#860]: https://github.com/ergebnis/json-normalizer/pull/860
[#861]: https://github.com/ergebnis/json-normalizer/pull/861
[#863]: https://github.com/ergebnis/json-normalizer/pull/863

[@BackEndTea]: https://github.com/BackEndTea
[@dependabot]: https://github.com/dependabot
Expand Down
2 changes: 1 addition & 1 deletion src/Vendor/Composer/VersionConstraintNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static function sortVersionConstraints(string $versionConstraint): strin
};

$sort = static function (string $a, string $b) use ($normalize): int {
return \strcmp(
return \strnatcmp(
$normalize($a),
$normalize($b),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#version-range",
"value-contains-packages-and-version-constraints": {
"combination-and-comma-exact-version-unsorted/01-without-spaces-trimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-comma-exact-version-unsorted/02-without-spaces-untrimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-comma-exact-version-unsorted/03-with-space-single-trimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-comma-exact-version-unsorted/04-with-space-single-untrimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-comma-exact-version-unsorted/05-with-space-double-trimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-comma-exact-version-unsorted/06-with-space-double-untrimmed": "0 1.2 12.3.4 2.3.4"
"combination-and-comma-exact-version-unsorted/01-without-spaces-trimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-comma-exact-version-unsorted/02-without-spaces-untrimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-comma-exact-version-unsorted/03-with-space-single-trimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-comma-exact-version-unsorted/04-with-space-single-untrimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-comma-exact-version-unsorted/05-with-space-double-trimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-comma-exact-version-unsorted/06-with-space-double-untrimmed": "0 1.2 2.3.4 12.3.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#version-range",
"value-contains-packages-and-version-constraints": {
"combination-and-space-exact-version-unsorted/01-with-space-single-trimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-space-exact-version-unsorted/02-with-space-single-untrimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-space-exact-version-unsorted/03-with-space-double-trimmed": "0 1.2 12.3.4 2.3.4",
"combination-and-space-exact-version-unsorted/04-with-space-double-untrimmed": "0 1.2 12.3.4 2.3.4"
"combination-and-space-exact-version-unsorted/01-with-space-single-trimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-space-exact-version-unsorted/02-with-space-single-untrimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-space-exact-version-unsorted/03-with-space-double-trimmed": "0 1.2 2.3.4 12.3.4",
"combination-and-space-exact-version-unsorted/04-with-space-double-untrimmed": "0 1.2 2.3.4 12.3.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#version-range",
"value-contains-packages-and-version-constraints": {
"combination-or-exact-version-unsorted/01-without-spaces-trimmed": "0 || 1.2 || 12.3.4 || 2.3.4",
"combination-or-exact-version-unsorted/02-without-spaces-untrimmed": "0 || 1.2 || 12.3.4 || 2.3.4",
"combination-or-exact-version-unsorted/03-with-single-space-trimmed": "0 || 1.2 || 12.3.4 || 2.3.4",
"combination-or-exact-version-unsorted/04-with-single-space-untrimmed": "0 || 1.2 || 12.3.4 || 2.3.4",
"combination-or-exact-version-unsorted/05-with-double-space-trimmed": "0 || 1.2 || 12.3.4 || 2.3.4",
"combination-or-exact-version-unsorted/06-with-double-space-untrimmed": "0 || 1.2 || 12.3.4 || 2.3.4"
"combination-or-exact-version-unsorted/01-without-spaces-trimmed": "0 || 1.2 || 2.3.4 || 12.3.4",
"combination-or-exact-version-unsorted/02-without-spaces-untrimmed": "0 || 1.2 || 2.3.4 || 12.3.4",
"combination-or-exact-version-unsorted/03-with-single-space-trimmed": "0 || 1.2 || 2.3.4 || 12.3.4",
"combination-or-exact-version-unsorted/04-with-single-space-untrimmed": "0 || 1.2 || 2.3.4 || 12.3.4",
"combination-or-exact-version-unsorted/05-with-double-space-trimmed": "0 || 1.2 || 2.3.4 || 12.3.4",
"combination-or-exact-version-unsorted/06-with-double-space-untrimmed": "0 || 1.2 || 2.3.4 || 12.3.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#version-range",
"value-contains-packages-and-version-constraints": {
"combination-or-version-range-caret-unsorted/01-without-spaces-trimmed": "^0 || ^1.2 || ^12.3.4 || ^2.3.4",
"combination-or-version-range-caret-unsorted/02-without-spaces-untrimmed": "^0 || ^1.2 || ^12.3.4 || ^2.3.4",
"combination-or-version-range-caret-unsorted/03-with-single-space-trimmed": "^0 || ^1.2 || ^12.3.4 || ^2.3.4",
"combination-or-version-range-caret-unsorted/04-with-single-space-untrimmed": "^0 || ^1.2 || ^12.3.4 || ^2.3.4",
"combination-or-version-range-caret-unsorted/05-with-double-space-trimmed": "^0 || ^1.2 || ^12.3.4 || ^2.3.4",
"combination-or-version-range-caret-unsorted/06-with-double-space-untrimmed": "^0 || ^1.2 || ^12.3.4 || ^2.3.4"
"combination-or-version-range-caret-unsorted/01-without-spaces-trimmed": "^0 || ^1.2 || ^2.3.4 || ^12.3.4",
"combination-or-version-range-caret-unsorted/02-without-spaces-untrimmed": "^0 || ^1.2 || ^2.3.4 || ^12.3.4",
"combination-or-version-range-caret-unsorted/03-with-single-space-trimmed": "^0 || ^1.2 || ^2.3.4 || ^12.3.4",
"combination-or-version-range-caret-unsorted/04-with-single-space-untrimmed": "^0 || ^1.2 || ^2.3.4 || ^12.3.4",
"combination-or-version-range-caret-unsorted/05-with-double-space-trimmed": "^0 || ^1.2 || ^2.3.4 || ^12.3.4",
"combination-or-version-range-caret-unsorted/06-with-double-space-untrimmed": "^0 || ^1.2 || ^2.3.4 || ^12.3.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#version-range",
"value-contains-packages-and-version-constraints": {
"combination-or-version-range-tilde-unsorted/01-without-spaces-trimmed": "~0 || ~1.2 || ~12.3.4 || ~2.3.4",
"combination-or-version-range-tilde-unsorted/02-without-spaces-untrimmed": "~0 || ~1.2 || ~12.3.4 || ~2.3.4",
"combination-or-version-range-tilde-unsorted/03-with-single-space-trimmed": "~0 || ~1.2 || ~12.3.4 || ~2.3.4",
"combination-or-version-range-tilde-unsorted/04-with-single-space-untrimmed": "~0 || ~1.2 || ~12.3.4 || ~2.3.4",
"combination-or-version-range-tilde-unsorted/05-with-double-space-trimmed": "~0 || ~1.2 || ~12.3.4 || ~2.3.4",
"combination-or-version-range-tilde-unsorted/06-with-double-space-untrimmed": "~0 || ~1.2 || ~12.3.4 || ~2.3.4"
"combination-or-version-range-tilde-unsorted/01-without-spaces-trimmed": "~0 || ~1.2 || ~2.3.4 || ~12.3.4",
"combination-or-version-range-tilde-unsorted/02-without-spaces-untrimmed": "~0 || ~1.2 || ~2.3.4 || ~12.3.4",
"combination-or-version-range-tilde-unsorted/03-with-single-space-trimmed": "~0 || ~1.2 || ~2.3.4 || ~12.3.4",
"combination-or-version-range-tilde-unsorted/04-with-single-space-untrimmed": "~0 || ~1.2 || ~2.3.4 || ~12.3.4",
"combination-or-version-range-tilde-unsorted/05-with-double-space-trimmed": "~0 || ~1.2 || ~2.3.4 || ~12.3.4",
"combination-or-version-range-tilde-unsorted/06-with-double-space-untrimmed": "~0 || ~1.2 || ~2.3.4 || ~12.3.4"
}
}

0 comments on commit 0f41f57

Please sign in to comment.