---
url: "https://vueda.dev/v3/reference/api/js/utils/sortedFields/functions/addSortField.md"
title: "addSortField"
---

# addSortField

## Overview

Append `base` to the sort order. No-op (returns a copy) when `base` is already present.

## Signature

`addSortField(sorted, base, options)`

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="param-sorted">sorted</span> | `string[]` | yes | The sort order. |
| <span id="param-base">base</span> | `string` | yes | The base field name to add. |
| <span id="param-options">options</span> | `object` | no | Initial direction; ascending by default. |

#### options Properties

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="param-options-descending">descending</span> | `boolean` | no |  |  |

### Returns

`string[]`

A fresh array.

## Source

`client/lib/utils/sortedFields.js:119`
