For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/array/ascend.md.

ascend

Creates an ascending comparator from an accessor function.

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

Usage

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

Creates an ascending comparator from an accessor function.

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.

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