Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Sorting a subset

by !1 (Hermit)
on Dec 12, 2003 at 21:20 UTC ( #314412=note: print w/replies, xml ) Need Help??


in reply to Sorting a subset

Hmmm.

for (map "A$_", sort { $a <=> $b } map /^A\d+$/ ? substr($_,1) : (), @ +array) { ...

Just another way. I am assuming you wanted numeric comparison. I also took the liberty of filtering out inputs not of the form A followed by numeric digits. Apologies for allowing neither negatives nor decimals.

Although:

for (sort grep /^A/, @array) { ...

Would work if you just want it for strings starting with A.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2021-09-19 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?