my @sorted = map { my ($n,$t) = split('|:|',$_,2); $t.'|:|'.$n } sort map { my ($n,$t) = split('|:|',$_,2); $t.'|:|'.$n } @origarray;