perl -le 'print for sort{($a=~/(\d+(\.\d+){3})/)[0]cmp($b=~/(\d+(\.\d+){3})/)[0]} qw(1.2.3.4 1.12.3.4);' 1.12.3.4 1.2.3.4