#!/usr/bin/perl -w %hash=( 89=>3, 45=>2, 1 =>5, 40=>3); foreach (sort { $a <=> $b } keys(%hash) ) { print "key: $_ value: $hash{$_}\n" }