On Thu Jun 27 19:45:16 2019, DJERIUS wrote:
Show quoted text> Given the list of versions
>
> v2.018
> v2.018_01
> v2.019
>
> I would expect that a sort using version objects would return the
> given order, but it doesn't:
>
> perl -Mversion -E 'say join qq[\n], sort { $a <=> $b } map { version-
> >parse($_) } qw[ v2.018_01 v2.018 v2.019 ]'
>
> v2.018
> v2.019
> v2.018_01
By using a leading v, these are parsed as dotted-decimal version numbers, not numeric version numbers. So the . is a separator, and the _ is ignored. The version number are therefore equivalent to:
v2.18.0
v2.19.0
v2.1801.0
So they are being sorted correctly. If you want them to be treated as numeric versions, don't include the leading v.