in reply to Hash help

You need to get the entire hash contents at once if you want to sort them, so you can't use each.

use HTML::Entities qw( encode_entities ); for my $id ( sort { $HASH{$a}{COUNT} <=> $HASH{$b}{COUNT} } keys(%HASH) ) { print "<tr>", "<td>", encode_entities($id), "</td>", "<td>", encode_entities($HASH{$id}{COUNT}), "</td>", "</tr>\n"; }

I also fixed the bug where you were treating plain text as HTML.

Swap $a and $b if you want to sort in descending order.