in reply to Array Sort
BUT, in most cases, I tend to simply pass through the data once creating the inverse hash to that:my @sorted; { local %_ = (); @sorted = sort { $_{ $a } ||= substr( $a, 3, 4 ) cmp $_{ $b } ||= substr( $b, 3, 4 ) } @array; }
Such a hash, using the key info as a hash key, tends to be more useful than a sorted array of keys in the subsequent processing.my %hash = map { substr( $_, 3, 4 ), $_ } @array;
Note: if the middle field should vary in length, then the expression ( split /\-/ )[1] should replace the substr function.
One world, one people
|
|---|