#!/usr/bin/perl -w use strict; use warnings; my %hash = ( 1=>'Acrobat', 2=>'Notes', 3=>'CorelDraw' ); my @array; for (keys(%hash)) { push @array, "$hash{$_}#$_"; } for (sort(@array)) { m/(\w+)\#(\d+)/; print "\n"; }