Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: sort array

by Kenosis (Priest)
on Apr 30, 2012 at 20:27 UTC ( #968146=note: print w/ replies, xml ) Need Help??


in reply to sort array

Another option (Schwartzian transform):

map{print "$_->[0]\n"} sort {$a->[1] cmp $b->[1]} map{[$_, (split)[2]]} @lines;

Sorts on third word from the left. Replace [2] with [-3] after (split) to sort on third word from the right.

Hope this helps!


Comment on Re: sort array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2015-07-29 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls