> Could someone tell me how to sort these files?
>
> As you can see they are already sorted in perl, but the problem is .7
is
> suppose to be before 10.
>
> to get this sort i used
> @list_of_files=sort @list_of_files;
>
> sorted EMX-1.15.0.17.37-EMX-1.15.0.17.36.dlcwrap
> sorted EMX-1.15.1.42.10-EMX-1.15.1.42.11.dlcwrap
> sorted EMX-1.15.1.42.10-EMX-1.15.1.42.9.dlcwrap
> sorted EMX-1.15.1.42.23-EMX-1.15.1.42.24.dlcwrap
> sorted EMX-1.15.1.42.24-EMX-1.15.1.42.25.dlcwrap
> sorted EMX-1.15.1.42.25-EMX-1.15.1.42.26.dlcwrap
> sorted EMX-1.15.1.42.7-EMX-1.15.1.42.8.dlcwrap
> sorted EMX-1.15.1.42.9-EMX-1.15.1.42.8.dlcwrap
A plain sort is equivalent to this:
sub stdsort { $a cmp $b };
@sorted = sort stdsort @unsorted;
$a and $b get set to array elements to be compared.
The sort code must return -1 if $a < $b, 0 if they are
the same, or 1 if $a > $b.
You need to do a custom sort procedure:
sub mysort { # compare $a and $b };
@sorted = sort mysort @unsorted;
For more general sort details, see
perldoc -f sort
In your specific case, you might want to separate
the text and numeric bits of $a/$b with a split on
'-' or maybe a regex, then breaking the numeric
down even further by splitting on '.', and then
separately comparing the bits like so:
$abit1 cmp $ bbit1 or
$abit2 <=> $bbit2 or
$abit3 <=> $bbit3 or ...
hth.