---
url: /reference/@cssdoc/markdown/functions/groupEntries.md
---
# Function: groupEntries()

```ts
function groupEntries(entries, groups?): EntryGroup[];
```

Defined in: [emitters/markdown/src/render.ts:209](https://github.com/thedannywahl/cssdoc/blob/main/emitters/markdown/src/render.ts#L209)

Bucket records into display groups for the sidebar and index. A record with `@group Foo` joins a group
labelled `Foo`; a record without one falls back to its [KIND_GROUPS](../variables/KIND_GROUPS.md) kind label. Order: any
`groups` labels first (in that order), then the kind groups in [KIND_GROUPS](../variables/KIND_GROUPS.md) order, then any
remaining custom groups in first-appearance order. Empty groups are dropped. A custom `@group` value
equal to a kind label merges into that kind group.

Records are name-sorted internally, so the result is deterministic regardless of input order — both
within each group and across the first-appearance custom groups. (`buildCssApi` already name-sorts;
this keeps direct callers of [buildSidebar](buildSidebar.md)/[renderIndex](renderIndex.md) consistent with it.)

## Parameters

### entries

readonly [`CssDocEntry`](../../core/interfaces/CssDocEntry.md)\[]

The records to group.

### groups?

readonly `string`\[]

Optional explicit label order; see [RenderIndexOptions.groups](../interfaces/RenderIndexOptions.md#groups).

## Returns

[`EntryGroup`](../interfaces/EntryGroup.md)\[]

The non-empty groups, in display order.
