Skip Menu |

This queue is for tickets about the version CPAN distribution.

Report information
The Basics
Id: 129925
Status: open
Priority: 0/
Queue: version

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.9924
Fixed in: (no value)



Subject: incorrect version comparisons
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
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.
CC: Diab Jerius <djerius [...] cpan.org>
Subject: Re: [rt.cpan.org #129925] incorrect version comparisons
Date: Fri, 28 Jun 2019 08:18:31 -0400
To: bug-version [...] rt.cpan.org
From: Diab Jerius <djerius [...] cpan.org>
Thanks for the clarification. Sorry about the noise. On Fri, Jun 28, 2019, 07:15 Graham Knop via RT <bug-version@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=129925 > > > On Thu Jun 27 19:45:16 2019, DJERIUS wrote:
> > 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. >