in reply to How can I sort my array numerically on part of the string?
my @sorted = sort byPrefix @s; # sort the keys numerically sub byPrefix { # make copies so originals are preserved my ( $x, $y ) = ( $a, $b ); # get prefixes $x =~ s/:.+//; $y =~ s/:.+//; # RV $_=0; $x < $y && $_--; $x > $y && $_++; $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I sort my array numerically on part of the string?
by AnomalousMonk (Archbishop) on Dec 01, 2020 at 21:55 UTC |