Skip to content

Commit 1637568

Browse files
Sander Toonenclaude
andcommitted
Document the sort array function
`sort` was implemented, registered, and tested, but had no entry in the language-service docs registry and was missing from the quick reference. - Add a `sort` entry to `BUILTIN_FUNCTION_DOCS` so IDE/playground hover and completions show its description and `a` / `f` (optional comparator) params. - Add a `sort` row to the Array Functions table in `docs/quick-reference.md`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 844e6a9 commit 1637568

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

docs/quick-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ This is a quick reference card. For detailed documentation, see [Expression Synt
8686
| `indexOf(arr, val)` | `indexOf([1, 2, 3], 2)` | 1 |
8787
| `join(arr, sep)` | `join([1, 2], "-")` | "1-2" |
8888
| `unique(arr)` | `unique([1, 1, 2])` | [1, 2] |
89+
| `sort(arr, fn?)` | `sort([3, 1, 2])` | [1, 2, 3] |
8990
| `map(arr, fn)` | `map([1, 2], x => x * 2)` | [2, 4] |
9091
| `filter(arr, fn)` | `filter([1, 2, 3], x => x > 1)` | [2, 3] |
9192
| `find(arr, fn)` | `find([1, 5, 2], x => x > 3)` | 5 |

packages/expreszo/src/registry/builtin/function-docs.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,17 @@ export const BUILTIN_FUNCTION_DOCS: Readonly<Record<string, FunctionDocs>> = {
394394
{ name: 'size', description: 'Positive integer chunk size.', type: 'number' }
395395
]
396396
},
397+
sort: {
398+
description:
399+
'Return a sorted copy of an array (the original is not mutated). With no comparator, ' +
400+
'values are sorted in natural ascending order. Optionally pass a comparator f(a, b) ' +
401+
'that returns a negative number, zero, or a positive number to order a before, equal ' +
402+
'to, or after b.',
403+
params: [
404+
{ name: 'a', description: 'Input array.', type: 'array' },
405+
{ name: 'f', description: 'Optional comparator (a, b) => number.', optional: true, type: 'function' }
406+
]
407+
},
397408
union: {
398409
description: 'Concatenate arrays and remove duplicates, preserving first-seen order. Element equality follows Set semantics (strict for primitives, reference for objects).',
399410
params: [

0 commit comments

Comments
 (0)