Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: sort based on column values

by irah (Pilgrim)
on Jun 22, 2009 at 04:34 UTC ( [id://773479]=note: print w/replies, xml ) Need Help??


in reply to sort based on column values

#!/usr/bin/perl use strict; use warnings; sub sortby_multiplecolumn { my ($val1, $val2, $val3, $val4, $val5, $val6, $val7, $val8, $val9) + = split(" ",$a); my ($val11, $val12, $val13, $val14, $val15, $val16, $val17, $val18 +, $val19) = split(" ",$b); $val9 <=> $val19; } print $_ foreach (sort sortby_multiplecolumn <STDIN>);

You will get what you want. Here I used space as a delimiter. You can use tab as delimiter or use '\s'.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (None)
    As of 2024-04-19 00:04 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found