Added new array_group_by helper function