On Wed, Dec 15, 2004 at 07:02:16AM +0900, Alex Fenton wrote:
> Hi
> 
> I tried the code below- I thought
> 
> [a, b].sort
> 
> was always the same as
> 
> [a, b].sort { | x, y | x <=> y }
> 
> and don't understand why it's not in this case. The String subclass 
> method doesn't seem to get called in the no-arg version?

static int
sort_2(ap, bp, data)
    VALUE *ap, *bp;
    struct ary_sort_data *data;
{

...

    if (TYPE(a) == T_STRING && TYPE(b) == T_STRING) {
        return rb_str_cmp(a, b);
    }


It bypasses #<=> for objects of class String and subclasses.

-- 
Hassle-free packages for Ruby?
RPA is available from http://www.rubyarchive.org/