SortSpec

The sorting specification.

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/spreadsheet/sort-spec#getBackgroundColor()` | `https://developers.google.com/apps-script/reference/spreadsheet/color|null` | Returns the background color used for sorting, or `null` if absent. |
| `https://developers.google.com/apps-script/reference/spreadsheet/sort-spec#getDataSourceColumn()` | `https://developers.google.com/apps-script/reference/spreadsheet/data-source-column|null` | Gets the data source column the sort spec acts on. |
| `https://developers.google.com/apps-script/reference/spreadsheet/sort-spec#getDimensionIndex()` | `Integer|null` | Returns the dimension index or `null` if not linked to a local filter. |
| `https://developers.google.com/apps-script/reference/spreadsheet/sort-spec#getForegroundColor()` | `https://developers.google.com/apps-script/reference/spreadsheet/color|null` | Returns the foreground color used for sorting, or `null` if absent. |
| `https://developers.google.com/apps-script/reference/spreadsheet/sort-spec#getSortOrder()` | `https://developers.google.com/apps-script/reference/spreadsheet/sort-order` | Returns the sort order. |
| `https://developers.google.com/apps-script/reference/spreadsheet/sort-spec#isAscending()` | `Boolean` | Returns whether the sort order is ascending. |

## Detailed documentation

### `getBackgroundColor()`

Returns the background color used for sorting, or `null` if absent.

#### Return


`https://developers.google.com/apps-script/reference/spreadsheet/color|null` --- The background color.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`

*** ** * ** ***

### `getDataSourceColumn()`

Gets the data source column the sort spec acts on. Returns `null` if this sort spec is
not acting on a data source column.

#### Return


`https://developers.google.com/apps-script/reference/spreadsheet/data-source-column|null` --- The data source column the sort spec acts on.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`

*** ** * ** ***

### `getDimensionIndex()`

Returns the dimension index or `null` if not linked to a local filter.

#### Return


`Integer|null` --- The dimension index.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`

*** ** * ** ***

### `getForegroundColor()`

Returns the foreground color used for sorting, or `null` if absent.

#### Return


`https://developers.google.com/apps-script/reference/spreadsheet/color|null` --- The foreground color.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`

*** ** * ** ***

### `getSortOrder()`

Returns the sort order.

#### Return


`https://developers.google.com/apps-script/reference/spreadsheet/sort-order` --- The sort order.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`

*** ** * ** ***

### `isAscending()`

Returns whether the sort order is ascending.

#### Return


`Boolean` --- `true` if the sort order is ascending, or `false` otherwise.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/spreadsheets.currentonly`
- `https://www.googleapis.com/auth/spreadsheets`