in reply to Negative number sorting?
Your array contains but a single element, and that element is an anymonous array (created with square brackets --- perhaps that is a typo when posting your code?). Use parentheses for ordinary list construction and remember that sort() does not sort in-place but instead returns the sorted list:
my @array = ( -15, 991, -9, 980, 1, 911, 281, 1299, 870, 1205, 1, 1 ); @array = sort { $a <=> $b } @array; print "@array\n"; __END__ -15 -9 1 1 1 281 870 911 980 991 1205 1299
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Negative number sorting?
by Ineffectual (Scribe) on Dec 29, 2001 at 01:39 UTC | |
by IlyaM (Parson) on Dec 29, 2001 at 01:44 UTC |