Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sorting records on a single field

by ack (Deacon)
on Jan 20, 2010 at 17:44 UTC ( [id://818515]=note: print w/replies, xml ) Need Help??


in reply to Sorting records on a single field

There are several good references in the Tutorials section of the Monestary on sorting. I would look in the subsection Getting Deeper Into Perl and the sub-subsection List Processing, Filtering, and Sorting. In particular you should look at transformational sorts; the Schwartzian Sort is, I think, one of the more popular that should meet your needs.

I would suggest, in particular, any one of three of the tutorials:

A brief tutorial on Perl's native sorting facilities by BrowserUK,

Resorting to Sorting by japhy, or

Complex sorting by vroom

The first is a good place to start, but the other two are really good, to, IMHO.

Good luck.

UPDATE: One thing I should've said (I didn't think about this until I got home last night) is that when you write your sort subroutine (which is what gives the transformation sorting...like the Schartzian Transformation sort, etc., their power...you'll need to parse each line of the input file to isolate the time data that you want to sort on. This will also mean that you'd need to read (slurp) the entire file into an array since the types of sorting mentioned in the references I posed do so in memory. There are some CPAN modules (e.g., Sort::Array) that I believe can sort files without having to slurp the entire file into memory...but I don't have any experience with them so I'm not sure if they can actually do that...maybe other Monks could guide you on that). Again, good luck.

ack Albuquerque, NM

Replies are listed 'Best First'.
Re^2: Sorting records on a single field
by almut (Canon) on Jan 20, 2010 at 18:05 UTC

      I just checked out that reference it is, indeed, an excellent reference. I did not know about it and found it a good reference to put my tool back of "places to look" for info on sorting. Thanks, almut.

      ack Albuquerque, NM

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found