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

[MacPerl] Sorting Arrays



I know I have done this routine before but it has been awhile.  I am
trying to sort the values of an array.  I went to run a test script (see
below) using the perlfunc.pod as guidance.  However, the sort doesn't
sort the values but the keys.  Am I missing something here.....


$test{'1'} = "z";
$test{'2'} = "a";
$test{'3'} = "q";

@test = sort { $age{$a} <=> $age{$a} } keys %test;

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

The output is:

1
2
3

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