push @holder, $key; ... my @holder_sorted = sort { $hash{$a} <=> $hash{$b} } @holder; print("@hash{@holder_sorted}\n");