mkurtis has asked for the wisdom of the Perl Monks concerning the following question:
However, i have an array full of other numbers that need to be sorted. Its scoring for a survey so that i know what surveys rank higher in terms of need. (its not for a class). The numbers were in a hash that are now put into an array. Only the (0) element of the array has them in it though. When i try to sort with just the array(0) it doesnt work.my @numbers= (6, 1, -3, 7, -1290); @sorted= reverse sort { $a <=> $b } (@numbers); print @sorted;
the above code only returns the numbers in the same order as in @score(0), which isnt in any order. I then tried splitting the numbers@sorted= reverse sort { $a <=> $b } (@score[0]); print @sorted;
that doesnt work either, it instead puts all of the values into @score(1), which also doesnt sort when plugged into the sorter. Does anyone know why this doesnt work? thanks@score= split(/\s/, @score[0]);
mkurtis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: splitting array values
by japhy (Canon) on May 20, 2004 at 00:20 UTC | |
|
Re: splitting array values
by bobn (Chaplain) on May 20, 2004 at 01:22 UTC | |
by mkurtis (Scribe) on May 20, 2004 at 01:44 UTC | |
by VSarkiss (Monsignor) on May 20, 2004 at 02:10 UTC | |
by mkurtis (Scribe) on May 20, 2004 at 04:05 UTC | |
|
Re: splitting array values
by bobn (Chaplain) on May 20, 2004 at 04:19 UTC | |
by mkurtis (Scribe) on May 22, 2004 at 03:20 UTC | |
by duff (Parson) on May 22, 2004 at 23:34 UTC | |
by mkurtis (Scribe) on May 23, 2004 at 00:05 UTC | |
by mkurtis (Scribe) on Jun 01, 2004 at 02:47 UTC | |
by dakedesu (Scribe) on Jun 01, 2004 at 03:32 UTC | |
by mkurtis (Scribe) on Jun 01, 2004 at 03:15 UTC | |
by mkurtis (Scribe) on May 22, 2004 at 22:39 UTC | |
by mkurtis (Scribe) on May 22, 2004 at 23:21 UTC | |
|
Re: splitting array values
by dakedesu (Scribe) on Jun 01, 2004 at 03:27 UTC | |
by mkurtis (Scribe) on Jun 05, 2004 at 03:46 UTC |