I'm curious why you want that ordering, but never mind. Here is a Schwartian transform method with priority ordering.
my @sorted_lines = map {join '.', @$_} sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] || $a->[2] cmp $b->[2] || $a->[3] cmp $b->[3]} map { [split '.'] } @lines;
Reading right-to-left, each element of @lines is transformed to a reference to an array of the dot seperated values. Then the transformed array is sorted with left-to-right priority in the elements. Only if a comparison of the zero-th elements comes up equal, is the one-th elements compared. That is from the short-circuit behavior of the || operator. Finally the sorted array is turned back into its original form with the join map.
Those transformations are done to avoid many expensive calls to split and the associated creation of temporary variables.
After Compline,
Zaxo
In reply to Re: Sorting @lines
by Zaxo
in thread Sorting @lines
by kanabrian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |