Skip to content

feat(builtins): implement sort -V version sort#918

Merged
chaliy merged 1 commit intomainfrom
feat/issue-907-sort-version
Mar 31, 2026
Merged

feat(builtins): implement sort -V version sort#918
chaliy merged 1 commit intomainfrom
feat/issue-907-sort-version

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 31, 2026

Summary

  • Implement sort -V (version/natural sort) for sorting version strings and filenames with embedded numbers
  • Adds version_cmp function that splits strings into non-digit and digit chunks, comparing numerically where appropriate
  • Added 5 spec tests covering basic versions, semver, filenames, reverse, and mixed content

Test plan

  • cargo test --test spec_tests -- bash_spec_tests passes
  • New tests: sort_version_basic, sort_version_semver, sort_version_files, sort_version_reverse, sort_version_mixed
  • cargo clippy -- -D warnings clean

Closes #907

Adds natural/version sort that compares strings by splitting into
alternating non-digit and digit chunks. Non-digit chunks compare
lexically; digit chunks compare numerically. Handles version strings
like 1.2.10 > 1.2.9 and file-1.10.txt > file-1.2.txt.

Closes #907
@chaliy chaliy merged commit 086a9f1 into main Mar 31, 2026
27 checks passed
@chaliy chaliy deleted the feat/issue-907-sort-version branch March 31, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sort: implement -V version sort

1 participant