Group By Property

Group array items by a property value.

Code

General
arr.group_by { |item| item[key] }

Parameters

Array of objects

Property to group by

Server

More Ruby Snippets