Sort_by to accept symbol?

hi

I was wondering whether it’d be useful for Array#sort_by to accept a
symbol as an alternative to a block for the sort rule.

So

my_array.sort_by(:foo)

would mean

my_array.sort_by { | elem | elem.send(:foo) }

It’s not so much to save typing as to make it neater to use sort_by in
chained method calls.

Any takers?

alex

I like it.

“alex fenton” alex@delete.pressure.to wrote in message
news:1085254048.531196@news01.eclipse.net.uk

···

hi

I was wondering whether it’d be useful for Array#sort_by to accept a
symbol as an alternative to a block for the sort rule.

So

my_array.sort_by(:foo)

would mean

my_array.sort_by { | elem | elem.send(:foo) }

It’s not so much to save typing as to make it neater to use sort_by in
chained method calls.

Any takers?

alex