From: Robert Klemme Date: 2005-08-04T02:11:05+09:00 Subject: Re: Cascading <=> comparisons Garance A Drosehn wrote: > On 7/16/05, Robert Klemme wrote: >> Garance A Drosehn wrote: >> >> Noone explicitely commented on the use of hash.keys.sort: >> this is quite inefficient. Instead doing the sort on the hash >> directly is much more efficient: > > I can see how this would be faster wrt execution, but if I use > hashobj.sort then I end up with an array of arrays which have > both the key-names and their values. Memory-wise, isn't that > going to be significantly larger than an array which only has > the key-names? When I wrote this, I mainly thought about the > memory usage, and I just assumed that the performance would > be "about-the-same" either way... > > I'll check over my actual script wrt this idea. It's probably true > that I would rather optimize the speed than the memory usage, > in which case I might take advantage of this. I'll certainly use > it in other scripts I write! Thanks. > > (note that in the actual script, the values are not simple integers, > but objects which in turn have a lot of instance-variables...) That doesn't make a difference as they are not copied. Mem overhead is just the temp arrays. Kind regards robert