Now the output is really what I would like it to be....#!/usr/bin/perl -w use strict; sub ByVersion; my @VersionList=("1.1","1.1.1","2.0","1.2_patch3","33.0","1.1.1.1","1. +a.1","1.b.1","1.b.1.a","1.b.1.b","1.33.0","1.0.a","1.0.b","33.1","6.6 +.6","10.0","9.0","3.1.4","3.1.12"); chomp (@VersionList); my @Sorted=sort ByVersion @VersionList; print "Sorted to: @Sorted\n"; sub ByVersion { my @First=split /\./,$a; my @Second=split /\./,$b; my $Nr=($#First>$#Second)?$#Second:$#First; foreach(0..$Nr) { next if ($First[$_] eq $Second[$_]); return ("$First[$_]$Second[$_]"=~/^\d$/o)?($First[$_] <=> $Second[$_ +]):($First[$_] cmp $Second[$_]); } return ($#First>$#Second)?1:-1; }
In reply to Sort ByVersion by ChOas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |