I''m using collection.select lists and I would love to sort them by one or two of the columns as the lists are getting long enough to make a difference. <%= options = [[''Select a Facility'', '''']] + @facility.collect { |fac| [fac.name, fac.id] } select ''placement'', ''facility_id'', options %> how do I get this to order by facility.name ? Craig
Craig White wrote:> <%= options = [[''Select a Facility'', '''']] + @facility.collect { > |fac| [fac.name, fac.id] } > select ''placement'', ''facility_id'', options %> > > how do I get this to order by facility.name ?<%= options = [[''Select a Facility'', '''']] + @facility.sort{|a,b| a.name <=> b.name }.collect{|fac| [fac.name, fac.id] } select ''placement'', ''facility_id'', options %> -- Alex
On Tue, 2006-02-28 at 17:11 +0000, Alex Young wrote:> Craig White wrote: > > <%= options = [[''Select a Facility'', '''']] + @facility.collect { > > |fac| [fac.name, fac.id] } > > select ''placement'', ''facility_id'', options %> > > > > how do I get this to order by facility.name ? > <%= options = [[''Select a Facility'', '''']] + > @facility.sort{|a,b| > a.name <=> b.name }.collect{|fac| > [fac.name, fac.id] } > select ''placement'', ''facility_id'', options %>---- thanks - at least I now recognize why I couldn''t intuitively figure this out. Craig