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

RE: Presort's Cost

by turnstep (Parson)
on Jul 26, 2000 at 17:59 UTC ( [id://24484]=note: print w/replies, xml ) Need Help??


in reply to Presort's Cost
in thread Efficiency and Large Arrays

Yes, simple sorting requires a lot of memory, but even a more complex sort requires that at the very least you read each record once. Why not just grab the information while you are there, as in my example program above? I agree that a sorted file is far better, and you'd probably want to get it sorted at some point, but I would not call it the only "sane" way! :)

Replies are listed 'Best First'.
Presort's Cost - 2
by gryng (Hermit) on Jul 26, 2000 at 18:15 UTC
    Oh yeah of course sorting is an expensive operation (but not too expensive). However, what I said was that if you didn't have enough memory to keep all of the records in then sorting is the only sane way to do it because otherwise you will either start thrashing or repeating work. I never do the sorting unless I start processing +1 meg files, and even then it depends on whether I care :) .

    Cheers,
    Gryn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://24484]
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: (1)
As of 2024-04-18 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found