Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Sort array

by choroba (Archbishop)
on Mar 05, 2020 at 22:38 UTC ( #11113882=note: print w/replies, xml ) Need Help??


in reply to Sort array

You can use a regex to extract the numbers:
#!/usr/bin/perl use strict; use warnings; use feature "say"; my @unsorted_array = qw( page1.html page11.html page2.html page3.html +); say for sort { ($a =~ /([0-9]+)/)[0] <=> ($b =~ /([0-9]+)/)[0] } @unsorted_array;
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11113882]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2020-05-24 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (142 votes). Check out past polls.

    Notices?