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

# toggleSortField

## Overview

Flip the direction of `base` in place within the sort order. No-op (returns a copy) when
`base` is absent; other entries keep their position and direction.

## Signature

`toggleSortField(sorted, base)`

### 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 toggle. |

### Returns

`string[]`

A fresh array.

## Source

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