Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Sorting a text file

by johngg (Canon)
on Mar 15, 2007 at 09:56 UTC ( [id://604951]=note: print w/replies, xml ) Need Help??


in reply to Sorting a text file

You could easily adapt the answer I gave to your question yesterday. Simply take out the @wanted array and the $rxExtract regex and replace the

grep { $_->[2] =~ $rxExtract }

with

sort { $a->[2] <=> $b->[2] }

Note that I have used a numerical comparison in the sort (<=>) just in case your second column has numbers of other than four digits. If there will always be only four digits you could use string comparison (cmp).

I hope this is of use

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found