in reply to finding highest number
Why do something C-style when you can speak simple Perlish?
my @sorted = sort {$b <=> $a} @numbers; my $highest = $sorted[0];
This sorts your array from highest to lowest and puts it in @sorted.
Update: changed "my $highest = $numbers[0];" to "my $highest = $sorted[0];" Many thanks to UnderMine for pointing this out.
John J Reiser
newrisedesigns.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (nrd) finding highest number
by gjb (Vicar) on Dec 05, 2002 at 13:04 UTC | |
by merlyn (Sage) on Dec 05, 2002 at 16:05 UTC | |
|
Re: Re: (nrd) finding highest number
by UnderMine (Friar) on Dec 05, 2002 at 15:02 UTC | |
|
Re: Re: (nrd) finding highest number
by Anonymous Monk on Dec 05, 2002 at 12:59 UTC | |
by gjb (Vicar) on Dec 05, 2002 at 13:07 UTC |