From: new2ruby@... (New 2 Ruby) Date: 2005-10-25T06:22:02+09:00 Subject: Re: [SORT?] by x,y allowing x,y to be passed as parms On Sun, 23 Oct 2005 19:02:37 -0600, "Ara.T.Howard" wrote: >On Mon, 24 Oct 2005, New 2 Ruby wrote: > >> Have class CD with several fields defined, >> @list_of_CDs array in class CD_List holding CD pointers, >> and a couple of methods to sort array of pointers by any two fields. >> > def initialize hash > hash.each{|k,v| send "#{ k }=", v} > end > def inspect > 'cd(' << ATTRIBUTES.map{|k| [k,send(k)].join('=')}.join(', ') << ')' > end > class CDList < ::Array > def sorted_by *keys > block = lambda{|cd| keys.flatten.map{|k| cd.send k}} > sort_by &block Thanks Ara. Yes, that will sort on one or more of the attributes of CD. Now, will work on understanding how it does it. Jim Email address is _invalid_! Read here; please respond here.