Skip to content

Instantly share code, notes, and snippets.

@fracai
Created July 14, 2012 01:56
Show Gist options
  • Save fracai/3108786 to your computer and use it in GitHub Desktop.
Save fracai/3108786 to your computer and use it in GitHub Desktop.
build and iterate a sorted hash of items by class and sequence
# build the classes hash
classes = Hash.new{|h, k| h[k] = []}
items.reject { |i| ! i[:class] }.each do |i|
classes[i[:class]] << i
end
# iterate each class, then each sequence in that class
classes.keys.sort.each do |class, class_items|
class_items.sort_by { |c| c[:sequence] }.each do |c|
#
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment