[EMAIL PROTECTED] wrote:
>
> I need to order a hash, called condorhash, based on the key value.
> So what I did is:
>
> my @condorhash = keys(%condorhash);
> sort @condorhash;
>
> Now I want to take the order of the array and apply it to the hash
> while keeping the values associated with the key. I know there is
> some way to make a pointer run down through the hash, but I don't
> know how.
You are using sort() in a void context which does NOT modify the array
@condorhash. The array is sorted but the results are not stored
anywhere. You should populate the array like this (you may also want to
name the array @condorkeys instead of @condorhash to avoid confusion):
my @condorkeys = sort keys %condorhash;
Or if the keys are numbers:
my @condorkeys = sort { $a <=> $b } keys %condorhash;
To diplay the contents of %condorhash using the values in an array:
for my $key ( @condorkeys ) {
print "$key $condorhash{$key}\n";
}
If you just want to print the values of %condorhash you could do this:
print @condorhash{ @condorkeys };
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]