> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# ascend

Creates an ascending comparator from an accessor function.

```typescript
users.sort(ascend(u => u.name))
```

## Usage

### `ascend<T>(fn: (value: T) => number | string)`

Creates an ascending comparator from an accessor function.

```typescript
import { ascend } from 'massaman'
// or:  import { ascend } from 'massaman/array'

users.sort(ascend(u => u.name))
```

#### Parameters


fn(value: T) => number | stringrequired

the function to apply.

#### Returns

an ascending comparator suitable for `Array.prototype.sort` or `toSorted`.

```typescript
(a: T, b: T) => number
```
