[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Sorting Arrays



Well, you aren't putting your data in an array in the first place, but in a
hash. What I guess you are trying to do is this:

$test[1] = 'z';
$test[2] = 'a';
$test[3] = 'q';

@test = sort {$a cmp $b} @test;

foreach $element (@test) {
   print "$element\n";
}

which would output


a
q
z

(with a blank line for $test[0], which is undefined)

You can't sort a hash, you can only sort its keys or values.

Regards,
Cajo.

___Carl_Johan_Berglund_________________________
   Adverb Information
   carl.johan.berglund@adverb.se
   http://www.adverb.se/



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org