my @sorted= grep { s#0.{4}(\d+)#$1#gs; 1 } sort grep { s#(\d+)#"0".pack("N",length$1).$1#ge; 1 } @{[ @list ]};