Re: [MacPerl-AnyPerl] sorting by hash value

2002-09-23 Thread allan
thank you works brilliantly! ../allan David Iberri wrote: > > Hi Allan, > > How about sorting the hash keys by their value, > instead of inverting the hash? > > my %presVocab = ( > 'nuclear' => 'nuculear', > 'terror' => 'terra', > 'horror' => 'horra' > ); > > my @keys_sorted_by_valu

Re: [MacPerl-AnyPerl] sorting by hash value

2002-09-23 Thread David Iberri
Hi Allan, How about sorting the hash keys by their value, instead of inverting the hash? my %presVocab = ( 'nuclear' => 'nuculear', 'terror' => 'terra', 'horror' => 'horra' ); my @keys_sorted_by_value = sort { $presVocab{$a} cmp $presVocab{$b} } keys %presVocab; foreach my $key(@keys

[MacPerl-AnyPerl] sorting by hash value

2002-09-23 Thread allan
hi is it possible to sort by the values in a hash if those values might be identical ? please try example below whcih will indeed sort the way i want, but will (obviously) discard duplicate keys in my reverse hash; anyone have a good idea for this ? ../allan _ %test = ( abc => 1230