Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Sort on Number Embedded in String

by sh1tn (Priest)
on Mar 23, 2005 at 10:00 UTC ( #441727=note: print w/replies, xml ) Need Help??


in reply to Sort on Number Embedded in String

... my $sort = sub { $_[0] =~ /$_[1]/ && $1 }; @data = sort { $sort->($a, qr/(\d+)/) <=> $sort->($b, qr/(\d+)/) } @data; print "@data" ... __END__ STDOUT: fwlog.1Mar2005.gz fwlog.2Mar2005.gz fwlog.3Mar2005.gz fwlog.4Mar2005.gz fwlog.5Mar2005.gz fwlog.6Mar2005.gz fwlog.7Mar2005.gz fwlog.8Mar2005.gz fwlog.9Mar2005.gz fwlog.14Mar2005.gz fwlog.15Mar2005.gz fwlog.16Mar2005.gz fwlog.17Mar2005.gz fwlog.18Mar2005.gz fwlog.19Mar2005.gz fwlog.20Mar2005.gz fwlog.21Mar2005.gz


Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://441727]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2018-04-25 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?