Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Sorting an array containing version numbers

by ikegami (Patriarch)
on Dec 23, 2009 at 01:04 UTC ( [id://814028]=note: print w/replies, xml ) Need Help??


in reply to Sorting an array containing version numbers

Ignoring the "very optimised way" request, here's a "nice a proper way"
use version; print "$_\n" for sort map version->declare($_), 2.4.74, 3.2.5, 1.14.56, 1.45.2, 3.14.75, 1.12.0, 1.2.0, 1.20.0;

Replies are listed 'Best First'.
Re^2: Sorting an array containing version numbers
by jffry (Hermit) on Feb 22, 2012 at 21:13 UTC

    To put those values in an array in sorted order using this technique, I had to do this:

    for (sort (map {version->declare($_)} @unsorted_versions)) { push @versions, (sprintf "%s", $_); }

    I also added () and {} to help my amateur mind see precedence and the for/sort/map boundaries easier.

      You just had to change print "$_\n" for to @versions =.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://814028]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-28 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found