Sort Question

I like the sort_by syntax. How stable is 1.7.2?


“I must hurry back to my comic book store, where I dispense the insults
rather than absorb them.”


-----Original Message-----
From: []
Sent: 06 September 2002 02:24
Subject: Re: Sort Question


In message “Re: Sort Question” on 02/09/06, Albert Wagner writes:

I want to sort the array (with these objects in it) by xnum…

ary = [,‘a’),,‘b’),,‘c’)]
sortedAry = ary.sort {|a, b| b.xnum <=> a.xnum}

If you are using 1.7, you can

sortedAry = ary.sort_by {|x| x.xnum}


NOTICE: This e-mail and any attachment(s) may contain confidential and
proprietary information of Goss International Corporation and/or its
subsidiaries and may be legally privileged. This e-mail is intended solely
for the addressee. If you are not the addressee, dissemination, copying or
other use of this e-mail or any of its content is strictly prohibited and
may be unlawful. If you are not the intended recipient please inform the
sender immediately and destroy the e-mail and any copies. All liability for
viruses is excluded to the fullest extent permitted by law. Any views
expressed in this message are those of the individual sender. No contract
may be construed by this e-mail.

I like it too, but can’t answer your question. Bear in mind, however, that you
can add it yourself to 1.6. I think there’s an implementation in Pickaxe. I
was surprised when I saw Matz’s example because I thought the syntax was:

ary.sort_by :xnum



----- Original Message -----
From: “Firestone, Mark - Technical Support”

I like the sort_by syntax. How stable is 1.7.2?