You could simply use @values = sort @values, since this checks the first two digits
They are not exactly the same thing.
Your method will only work if every element had the same number of digits. If you were to compare "1abc" and "10abc", it would give you the wrong order.
perl -e '@array=(qw(1abc 10abc));@sorted=sort @array; print "@sorted\n +";' 10abc 1abc perl -e '@array=(qw(1abc 10abc)); @sorted = sort {$a<=>$b} @array; print "@sorted\n";' 1abc 10abc
In reply to Re: Re: substr sort ??
by dbwiz
in thread substr sort ??
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |