Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: sort using <=>

by Roy Johnson (Monsignor)
on Aug 13, 2004 at 20:22 UTC ( [id://382826]=note: print w/replies, xml ) Need Help??


in reply to Re^2: sort using <=>
in thread sort using <=>

Looks to me like you want something like this Schwartzian Transform:
#open your files as before, then print FOO map { $_->[1] } sort { $a->[0] <=> $b->[0] } map {my @F=split; [substr($F[2],1), $_]} <D>; #close your files as before
Reading from bottom to top, we construct an array of arrays, where the first element of each element is the sort-field, and the second is the print-field. Then we sort by comparing the sort fields, then we return only the print-fields to print.

Updated to work on the data provided.


Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-28 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found