in reply to Re: substr sort ??
in thread substr sort ??
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: substr sort ??
by CombatSquirrel (Hermit) on Aug 22, 2003 at 15:42 UTC |