%hash=( 1 => [ 51, 'a2'], 2 => [42, 'a1'] ); print "$_ => @{$hash{$_}}" for map substr($_,2), sort map {pack("C2", $hash{$_}[0])."$_"} keys %hash;