From: "Benjamin J. Tilly" Date: 2001-05-17T00:18:32+09:00 Subject: [ruby-talk:15283] Re: Pluggable sorting - How would you do it? >===== Original Message From ts ===== >>>>> "B" == Benjamin J Tilly writes: > >B> p [StringReverse.new("hello"), StringReverse.new("world")].sort > > When no block is given, #sort is hard-coded if the 2 elements are FIXNUM > or String > Ick? I would think that a better optimization would be to instead implement sort internally as a Schwartzian sort - do the method lookups on the way in so they are immediately available inside. That would still get a speed boost, but would move the breakage to the case of someone trying to redefine their methods inside of the comparison. I kind of feel that anyone trying to do that deserves what they get... Cheers, Ben