On 2/6/08, Rob Saul <wyrd / code-gnomemad.org> wrote:
> I came across this :
>         elements.sort_by(&:position).each
> in something I've taken over.  I thought sort_by
> took a block.  Obviously I'm missing something.
> Can anyone shed some light on this trick?

Sure. &:position == :position.to_proc == proc { |element, *args|
element.position(*args) }

So elements.sort_by(&:position) is shorthand for sorting the elements
by position.

jeremy