From: bdarcus@... Date: 2005-06-26T23:30:39+09:00 Subject: grouping/sorting [newbie question] I'm trying to do something fairly simple that I understand how to do in XSLT, but not in Ruby. I have a list of film recommendations, with comments, in a yaml file that looks like this: - title: Lost in translation setting: Tokyo comments: Some comments.. - title: Chungking Express setting: Hong Kong comments: > Some comments. Since a film may have more than one entry, I want to create a list that groups the comments by film. So I'd like output like: Some Film ======= Comment 1. Comment 2. However, while I figured out how to sort the list correctly, I don't really understand how to do the grouping. Could someone please explain? Current code: require 'yaml' films = YAML::load(File.open("film.yaml")) sorted = films.sort_by{|film| film["title"]} sorted.each do |item| # I want to put the title for a group here, # then list the comments. if item["comments"] : puts item["comments"] else '' end end Bruce