my @sorted_words; foreach (@sorted_scores) { push(@sorted_words, $HashA{$_}; }