I like the sort_by syntax. How stable is 1.7.2?
Mark
[---------]
“I must hurry back to my comic book store, where I dispense the insults
rather than absorb them.”
[---------]
···
-----Original Message-----
From: matz@ruby-lang.org [mailto:matz@ruby-lang.org]
Sent: 06 September 2002 02:24
To: ruby-talk@ruby-lang.org
Subject: Re: Sort Question
Hi,
In message “Re: Sort Question” on 02/09/06, Albert Wagner alwagner@tcac.net writes:
I want to sort the array (with these objects in it) by xnum…
ary = [Area_rep.new(1,‘a’), Area_rep.new(2,‘b’), Area_rep.new(3,‘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}
matz.
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.