container.sort_by {|x| x[2]}

On 10/13/06, Dominic Son <dominicson / gmail.com> wrote:
> But how to do apply this to having 3 elements in the value of an array?
>
> container.sort_by { |x,y,z| *lost here*
>   puts x  <br>
>   puts y  <br>
>   puts z  <br>
>                   }
>
> Brian Mitchell wrote:
> > On 10/13/06, Dominic Son <dominicson / gmail.com> wrote:
> >> What method should i use?
> > Actually, the better way to sort in this scenario is to use sort_by.
> >
> > container.sort_by {|x| x[1]}
> >
> > No need to mess with the <=> operator by hand.
> >
> > Brian.
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
>