#!/usr/bin/perl use strict; use warnings; my %hash = ( '[foo]' => [3], '[bar]' => [2], '[buz]' => [1], '[qiz]' => [undef], ); print 'K: '. $_ .' V: '. $hash{$_}->[0] . "\n" for sort { $hash{$a}->[0] <=> $hash{$b}->[0] } grep { defined $hash{$_}->[0] } keys %hash;