in reply to Aid for regex expression
This is probably not helpful but it is fun. :P
use strictures; use List::Util "shuffle"; # Randomize the order my @stuf = shuffle qw( namem1100.111 namem0900.111 namem0010.111 namep +0000.111 namep0800.111 namep9999.111 ); print join("\n", "Before-", @stuf), $/; # Update: didn't mean to leave this -> no warnings "uninitialized"; @stuf = map $_->[0], sort { $a->[3] <=> $b->[3] } map { /name([mp])(\d{4}\.\d{3})/; [ $_, $1, $2, $1 eq "m" ? (0-$2) : (0+$2) ] } @stuf; print join("\n", "After-", @stuf), $/;
See Schwartzian Transform and https://en.wikipedia.org/wiki/Schwartzian_transform.
|
|---|