"heinous (sent by Nabble.com)" <lists / nabble.com> wrote in message 
news:3442515.post / talk.nabble.com...
>
>> You cannot use @attr, @attr is reserved for instance variables.  Also, 
>> it's
>> a bad idea to use instance variables (@tmparray, @tmphash) as temporary
>> variables.
>
> Gotcha there, I wasn't planning to, it was more to make the variable more
> obvious in the example.

It's generally preferred to use pieces of code that are syntactically 
correct and do something.  That makes everyone's lives easier. :-)

>> It's a one liner:
>> objects.sort_by {|o| o.send(attr)}
>
> Exactly what I needed, thanks... Now we're just looking at something 
> like:
>
>  def sort_obj(objects,attr)
>    objects.sort_by {|o| o.send(attr)}
>  end

Not really worth a method IMHO bur YMMV.

Kind regards

    robert