Gunnar Hjalmarsson <mailto:[EMAIL PROTECTED]> wrote:
: Edward Wijaya wrote:
: :
: : my $t = Tie::IxHash->new(%hash);
: : $t->SortByValue; # ascending, ok!
: :
: : $t->$hash{$b}<=>$hash{$a}SortByValue; # tried this but
: : # doesn't work
:
: Where in the docs for Tie::IxHash did you find that syntax?
: You can obviously not just guess and hope that Perl will
: read your mind.
I think Ed is getting 'sort' mixed in there. Gunnar's
right, Ed. You can't just make syntax up. (Well, not
without a lot more programming, anyway.)
: Did you possibly consider to use the Reorder method?
This is a tough one. You need to supply a list of keys
to the Reorder() method. Getting the list of keys already
sorted by value may not be apparent to a beginner.
If "$t->SortByValue()" sorts the hash by values, then
"$t->SortByValue()->Keys()" will return the keys for that
sort. We want to supply the reverse of those keys.
$t->Reorder( reverse $t->SortByValue()->Keys() );
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>