in reply to Re^3: In-place sort with order assignment
in thread In-place sort with order assignment
I've never really tried to optimize code to minimize memory usage, so my thoughts here might be stupid and/or crazy. I'll go ahead and risk being ridiculed and toss out my ideas in case they might spark a better idea from a more experienced programmers.
Marshall, your idea of sorting from a file is close to an idea that I had, but was very hesitant to put it in a post. However, it seems to me that sorting the file(s) as you suggest could potentially eat up a lot of memory. I admit that I could be dead wrong about that.
Here's my stupid/crazy idea that's close to what Marshall suggested:
In other words, instead of doing the sorting after populating the file with all of the hash keys, do the sorting one element at a time as each hash key is added to the file.
I believe that this would sort the keys with minimal memory usage. However, execution time might not be that great or even take too long. Since BrowserUK said that "Speed is not a huge priority here", this might be acceptable depending on how long it takes.
As I said, I have no experience optimizing for minimal memory usage, which means that this could be a horrible idea. I'm open to constructive criticism on this idea, which will help me learn more about optimizing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: In-place sort with order assignment
by Marshall (Canon) on Sep 20, 2010 at 03:46 UTC | |
by dasgar (Priest) on Sep 20, 2010 at 05:06 UTC |