>>>>> "Jeff" == Jeff 'Japhy' Pinyan <[EMAIL PROTECTED]> writes:
Jeff> On Feb 13, Frank said:
>> $max= (sort @values)[-1];
Jeff> You're sorting ASCIIbetically. You must sort numerically:
Jeff> (sort { $a <=> $b } @values)[-1];
>> Personally, I'd prefer Japhy's method for efficiency.
Jeff> Yeah, me too. ;) Sorting to find a min or max is not a good move.
Somebody benchmarked it somewhere recently, and for under 20 or 30
items (I forget the threshold), it was actually faster to *sort* it
than to do the normal high-water-mark algorithm!
Yes, it was counter-intuitive, which is why I remember that. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]