in reply to how do i sort hash values?

It is difficult to divine from your question but my guess is that you want to tag each letter in a word with it's rank in reverse alphabetic order. If that is the case your "bioinfo" example should actually be "5313241" since "f" comes before "i" and "n". This script works by building a hash table of letters in the word with their rank in reverse alpha order.

use strict; use warnings; my @words = qw{bioinfo alpha different}; foreach my $word (@words) { print qq{$word\n}; my $rhRank = rank($word); print qq{$_ -- $rhRank->{$_}\n} for split m{}, $word; } print qq{\n}; sub rank { my $word = shift; my %seen = (); my $index = 0; my $rhRank = { map {$_, ++ $index} sort {$b cmp $a} grep {! $seen{$_} ++} split m{}, $word }; }

When run for three words it produces

bioinfo b -- 5 i -- 3 o -- 1 i -- 3 n -- 2 f -- 4 o -- 1 alpha a -- 4 l -- 2 p -- 1 h -- 3 a -- 4 different d -- 7 i -- 4 f -- 5 f -- 5 e -- 6 r -- 2 e -- 6 n -- 3 t -- 1

I hope I have guessed correctly and this is of use.

Cheers,

JohnGG

Replies are listed 'Best First'.