my @lines; while (my ($k, $v) = each %{$href}) { push @lines, pack('NA*', -$v, "$k\t$v") } say substr($_, 4) for sort @lines;