in reply to probems with sorting file in perl

You say you want to sort on the first field only, yet you use -k 1, 3, which is sorting on 3 fields. Anyway, some untested code:
my $i = 0; open my $fh, "input_file.txt" or die; open my $oh, "> ss.txt" or die; print $oh map {(unpack "NNA*", $_) [-1]} sort map {pack "NNA*", (/(\d+)/) [0], $i ++, $_} <$fh>; close $fh or die; close $oh or die; rename "ss.txt", "input_file.txt" or die;