Problem
sort -V (version/natural sort) is parsed as a flag in sortuniq.rs but not implemented. Version sort is commonly used for sorting filenames, package versions, and semantic version strings.
Expected behavior
printf '1.10\n1.2\n1.1\n' | sort -V
# 1.1
# 1.2
# 1.10
Segments of digits are compared numerically, non-digit segments are compared lexically. This handles cases like file-1.2.txt vs file-1.10.txt correctly.
Current code
sortuniq.rs:149 — 'V' flag is matched but no version comparison logic exists. Falls through to default lexical sort.
Suggested approach
uutils/coreutils (MIT) has a version comparison implementation. The algorithm is non-trivial (splitting strings into numeric/non-numeric chunks, comparing each chunk appropriately). Consider borrowing their version_cmp logic — it's pure string comparison with no FS dependency.
References
Problem
sort -V(version/natural sort) is parsed as a flag insortuniq.rsbut not implemented. Version sort is commonly used for sorting filenames, package versions, and semantic version strings.Expected behavior
Segments of digits are compared numerically, non-digit segments are compared lexically. This handles cases like
file-1.2.txtvsfile-1.10.txtcorrectly.Current code
sortuniq.rs:149—'V'flag is matched but no version comparison logic exists. Falls through to default lexical sort.Suggested approach
uutils/coreutils (MIT) has a version comparison implementation. The algorithm is non-trivial (splitting strings into numeric/non-numeric chunks, comparing each chunk appropriately). Consider borrowing their
version_cmplogic — it's pure string comparison with no FS dependency.References
-V: https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html