Skip to content

Different behavior of version comparison comparing "GNU sort" #27

@sylvestre

Description

@sylvestre

Feel free to wontfix my request because I do get that it is nitpicking :)

I am considering your lib to replace some of the logic in the rust coreutils
https://github.com/uutils/coreutils/blob/main/src/uucore/src/lib/mods/version_cmp.rs#L57

I noticed that GNU sort version a bit differently than version-compare:

$ echo "
5.4.0
5.04.0"| sort --stable --sort=version
5.4.0
5.04.0

With this crate, the following code is failing:

use version_compare::{compare, compare_to, Cmp, Version};

fn main() {
    let a = "string start 5.04.0 end of str";
    let b = "string start 5.4.0 end of str";
    assert_eq!(a > b, true);
}

as the code considers that 5.04.0 is smaller than 5.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions