From: new2ruby@... (New 2 Ruby) Date: 2005-10-25T10:27:02+09:00 Subject: Re: [SORT?] by x,y allowing x,y to be passed as parms On Mon, 24 Oct 2005 11:27:35 +0900, "David A. Black" wrote: >Hi -- > >On Mon, 24 Oct 2005, New 2 Ruby wrote: > >> Question: Are there better ways to do this >> sort within the container class? > def new_ord(key1='size',key2='cusip') > @cds.replace(@cds.sort_by {|cd| [cd.send(key1), cd.send(key2)] }) > end .... > p cdl.new_ord > Aah, thank you. Just what the Dr. ordered. Adding a pinch of Ara Howard to generalize for n attributes: def new_ord(*args) @cds.replace(@cds.sort_by {|cd| args.map {|a| cd.send a }}) end .... p cdl.new_ord('size','cusip') Email address is _invalid_! Read here; please respond here.