---
title: "largestSubset(groupedBy:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/sequence/largestsubset(groupedby:)"
---

# largestSubset(groupedBy:)

Returns the largest group of donations when grouped by the specified key path.

## Declaration

```swift
func largestSubset<DonationInfo, Value>(groupedBy keyPath: KeyPath<DonationInfo, Value>) -> [Self.Element] where DonationInfo : Decodable, DonationInfo : Encodable, DonationInfo : Sendable, Value : Hashable, Self.Element == Tips.Event<DonationInfo>.Donation
```

## Parameters

- `keyPath`: A key path to a Hashable property on the donation value to group by.

## Return Value

Return Value An array of donations belonging to the largest group.

## Discussion

Discussion Use this method inside a Tips/Rule predicate to find the most frequently donated value for a given property. #Rule(LandmarkDetail.didViewLandmarkDetail) {     $0.donations.largestSubset(groupedBy: \.landmarkID).count >= 5 }
