# simple and effective: @sorted = (sort(grep!/:/,@data), sort(grep/:/,@data)); # or to avoid grepping @data twice: (probably not much gain) my (@colo, @noco); /:/ ? push @colo, $_ : push @noco, $_ for @data; @sorted = (sort(@noco), sort(@colo));