in reply to Re^3: sort an array with +ve & -ve numbers in it
in thread sort an array with +ve & -ve numbers in it
Very true, corrected code:
my @array = ( 99, 67, 0, -100, -38, 98); my ($min, $max) = (sort {$a <=> $b} @array)[0,-1];
Update: Cut n paste error fixed, thanks plobsing and ikegami
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: sort an array with +ve & -ve numbers in it
by plobsing (Friar) on Apr 05, 2009 at 14:28 UTC |