in reply to largest number inside array/hash
For searching among the keys of a hash, just replace @arr with keys %hash.my $max; grep($max=($_>$max)?$_:$max,@arr);
Sorting a whole array just to find the largest element is waay overkill - you do too many comparisons, and you have to move the elements around. It doesn't really matter for arrays that have ten or so elements, but as soon as you get to thousands, you will start noticing the difference.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: largest number inside array/hash
by Anonymous Monk on Apr 07, 2004 at 04:39 UTC | |
by matija (Priest) on Apr 07, 2004 at 05:39 UTC |