On 10/8/07, Eric Hodel <drbrain / segment7.net> wrote: > Profiling indicated a significant amount of time was spent in #<=> > which created more objects and called more methods than #sort_by. > Replacing #sort with #sort_by and #sort_obj reduced both. Creating > fewer objects and using less memory aren't the same thing. > > (Also, Rick's benchmark shows Array#sort cheating more than any other > effect.) First of all it's not my benchmark, it comes directly from the ri doc for sort_by Second, I don't understand the concept of Array#sort "cheating" this isn't a contest. Some things perform better with sort, others with sort_by. The performance of sort is generally determined by the cost of doing the <=> comparison, while the performace of sort_by is generally determined by the cost in time and space of creating the side array. As the English say, Horse for courses. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/