<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) &gt; [groupBy](./brick-next-pipes.groupby.md)

## groupBy() function

把一个集合按指定属性（或迭代器执行结果）的值进行分组。

 Collection

**Signature:**

```typescript
export declare function groupBy(collection: unknown[] | Record<string, unknown>, iteratee: string | number): Record<string, unknown[]>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  collection | unknown\[\] \| Record&lt;string, unknown&gt; | 数据结合。 |
|  iteratee | string \| number | 属性名（或迭代器）。 |

**Returns:**

Record&lt;string, unknown\[\]&gt;

分组结果。

## Remarks

透传调用 [\_.groupBy](https://lodash.com/docs/#groupBy)<!-- -->。

## Example


```ts
groupBy([6.1, 4.2, 6.3], Math.floor);
// => { '4': [4.2], '6': [6.1, 6.3] }

groupBy(['one', 'two', 'three'], 'length');
// => { '3': ['one', 'two'], '5': ['three'] }
```


