Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 imbibing at the Monastery: (7)
As of 2020-06-01 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?