Semver icon

Semver

Semantic Versioning utilities for version management

Sorting → Reverse Sort

AI-generated

Overview

The node provides utilities for working with semantic versioning (semver) strings. Specifically, the "Sorting" resource with the "Reverse Sort" operation sorts a list of version strings in descending order according to semver rules. This is useful when you want to prioritize or display versions from newest to oldest.

Common scenarios include:

  • Sorting software release versions to find the latest releases first.
  • Organizing dependency versions in reverse chronological order.
  • Preparing version lists for display or further processing where the highest version should appear first.

Example: Given versions 1.2.3, 1.2.4, 1.3.0, the node will output them sorted as 1.3.0, 1.2.4, 1.2.3.

Properties

Name Meaning
Versions Comma-separated list of version strings to sort, e.g., "1.2.3,1.2.4,1.3.0"
Options Collection of optional flags affecting parsing and sorting behavior:
- Loose: Whether to use loose parsing for version strings (boolean)
- Include Prerelease: Whether to include prerelease versions in range matching (boolean)
- RTL (Right to Left): Not applicable for this resource-operation combination

Output

The node outputs a JSON object containing:

  • operation: The string "rsort" indicating the reverse sort operation.
  • versions: The original array of input versions (trimmed).
  • result: An array of version strings sorted in descending semver order.

Example output JSON structure:

{
  "operation": "rsort",
  "versions": ["1.2.3", "1.2.4", "1.3.0"],
  "result": ["1.3.0", "1.2.4", "1.2.3"]
}

No binary data output is produced by this node.

Dependencies

  • Uses the external semver library for all version parsing and sorting logic.
  • No external API keys or services are required.
  • No special environment variables or n8n credentials needed.

Troubleshooting

  • Invalid Version Strings: If any version string is malformed or not semver-compliant, the sorting may fail or produce unexpected results. Use the "Validation" resource to check version validity before sorting.
  • Empty Input: Providing an empty or whitespace-only versions string will result in an empty output array.
  • Loose Parsing Option: Enabling "Loose" parsing can help handle non-strict semver strings but may lead to different sorting results.
  • Include Prerelease: If prerelease versions are present and not included, they might be excluded or sorted differently.

Common error messages:

  • "Unknown resource: sorting" — indicates the resource parameter was set incorrectly.
  • Errors related to invalid version formats usually come from the underlying semver library; ensure input versions conform to semver standards or enable loose parsing.

Links and References

Discussion