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/descend.md.

descend

Creates a descending comparator from an accessor function.

users.sort(descend(u => u.age))

Usage

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

Creates a descending comparator from an accessor function.

import { descend } from 'massaman'
// or:  import { descend } from 'massaman/array'

users.sort(descend(u => u.age))

Parameters

fn(value: T) => number | stringrequired

the function to apply.

Returns

a descending comparator suitable for Array.prototype.sort or toSorted.

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