my %hash = ( foo => 2, bar => 1, baz => 3, bun => 2, ); my @array = sort {$hash{$a} <=> $hash{$b}} keys %hash;