On 28 May 2002 21:36, Michael Fowler [mailto:[EMAIL PROTECTED]] wrote:
> On Tue, May 28, 2002 at 01:20:48PM -0700, Eric Wang wrote:
> > @result = sort @array
> > 
> > it sorts the numbers by digits, but not the whole number
> > for example 6666 is bigger than 443322341 because it's 
> first digit is a 6
> 
> Your question was answered by a another poster.
> 
> I'll reiterate:
> 
> see perldoc -f sort
> 
> The sort routine sorts alphabetically (well, ASCIIbetically) 
> by default, use
> a different comparison operator:
> 
>     @result = sort { $a <=> $b } @array;
> 
> 


This is worth repeating in general (sorry, Eric, to pick on you but this is
a rather too good example to miss)

If you do something, and it does not quite do what you expect, then the
first thing to do is RTFM. We all, from time to time, miss remember the
exact semantics of a function/method/property usually just by enough to
screw up what we have just written and a careful re-read of the
documentation can very quickly correct our memory.

(Just my 2p.)

Richard Cox 
Senior Software Developer 
Dell Technology Online 
All opinions and statements mine and do not in any way (unless expressly
stated) imply anything at all on behalf of my employer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to