Why don't you do it at the database with an order by? - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
On Wed, Feb 25, 2009 at 1:04 PM, Remco Swoany <[email protected]> wrote: > > Maurício Linhares wrote: >> departures = [ 'AMS', 'BCN', 'BBK' ] >> sums = {} >> departures.each do |d| >> sums[d] ||= 0 >> sums[d] = sums[d] + 1 >> end >> puts( sums ) >> >> - >> Maur�cio Linhares >> http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ >> (en) >> >> >> >> On Tue, Feb 24, 2009 at 2:57 PM, Remco Swoany > > Hi Maurício, > > Thanks for your reply. > > I have more bookings from the same departures, like this: > > departures = [ 'AMS', 'BCN', 'BKK', 'AMS', 'AMS', 'BKK'] > > Then i want to count the departures, like this based on the array above: > > AMS => '3' > BCN => '1' > BKK => '2' > > Is this possibly? > > (the objective is to store the values in a graph for management-info) > > Thanks in advance.. > > remco > > > > > > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

