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 =.