# File lib/active_support/core_ext/enumerable.rb, line 22 def group_by assoc = ActiveSupport::OrderedHash.new each do |element| key = yield(element) if assoc.has_key?(key) assoc[key] << element else assoc[key] = [element] end end assoc end