in reply to natural sort on array of arrays
I also tried to adapt something I found on this forum, but I don't fully understand it.
my @sorted_matrix = grep {s/(^|\D)0+(\d)/$1$2/g,1} sort {$a->[0] cmp $b->[0]} grep {s/(\d+)/sprintf"%06.6d",$1/ge,1} @matrix;
It zero-pads the numbers for the purposes of sorting and then removes the padding once the sort is complete. Sounds like a sensible approach.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: natural sort on array of arrays
by AnomalousMonk (Archbishop) on May 10, 2016 at 19:18 UTC |