I think you will want to use the new group_by function. Here is an
example:
p = Person.find(:all)
grouped = p.group_by(&:center)
Now ‘grouped’ is a hash where the key is ‘center’ and the value of the
hash is the groups of people.
Now you can do:
grouped.each do |center, person|
puts center
person.each do |p|
List out the people
end
end
Further reading at:
http://weblog.rubyonrails.org/articles/2006/03/01/new-in-rails-enumerable-group_by-and-array-in_groups_of