Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Sorting on Section Numbers

by acme (Novice)
on Jul 28, 2000 at 18:48 UTC ( #24858=note: print w/replies, xml ) Need Help??

in reply to Sorting on Section Numbers

Of course, there is a module on CPAN which does what you want! It's called Sort::Versions, available from and it basically does what you want:

use strict;
use Sort::Versions;

my @sections = qw(2.1.7 2.2 3.4a 2.13 1 2);
@sections = sort versions @sections;
print "@sections\n"; # prints "1 2 2.1.7 2.2 2.13 3.4a"
Hope this helps! Leon

Replies are listed 'Best First'.
Re: Re: Sorting on Section Numbers
by tye (Sage) on Jul 28, 2000 at 18:59 UTC

    Unfortunately, this module fails for some simple cases:

    use Sort::Versions; print join(" ",sort versions qw(1.2a 1.10a)),"\n";
    1.10a 1.2a

    Note that this matches the behavior described in the module's documentation, but I think it isn't what most people would want.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://24858]
[Corion]: Hmm - the longer I work, the more such sentences I collect:
[Corion]: "If I wanted to work with people, I would have become a coroner."
[Corion]: "If I wanted to work with hot air, I would have become a baloonist"
[Corion]: "If I wanted to work with flaps, I would have become a mailman"
[Corion]: (I'm not sure if the last one works in English too ;) )
[Eily]: it doesn't work in French AFAIK
[Eily]: I like the first one though :)
[erix]: balloonist, surely :P (or maybe baloneyist)

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-09-21 14:30 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (248 votes). Check out past polls.