Class SortSpec

  • SortSpec represents the sorting specification.

  • It includes methods to retrieve background and foreground colors used for sorting.

  • It can get the data source column or the dimension index the sort spec acts on.

  • SortSpec provides access to the sort order and indicates whether the sort order is ascending.

SortSpec

The sorting specification.

Methods

MethodReturn typeBrief description
getBackgroundColor()Color|nullReturns the background color used for sorting, ornull if absent.
getDataSourceColumn()DataSourceColumn|nullGets the data source column the sort spec acts on.
getDimensionIndex()Integer|nullReturns the dimension index ornull if not linked to a local filter.
getForegroundColor()Color|nullReturns the foreground color used for sorting, ornull if absent.
getSortOrder()SortOrderReturns the sort order.
isAscending()BooleanReturns whether the sort order is ascending.

Detailed documentation

getBackgroundColor()

Returns the background color used for sorting, ornull if absent.

Return

Color|null — The background color.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataSourceColumn()

Gets the data source column the sort spec acts on. Returnsnull if this sort spec isnot acting on a data source column.

Return

DataSourceColumn|null — The data source column the sort spec acts on.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDimensionIndex()

Returns the dimension index ornull 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 followingscopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getForegroundColor()

Returns the foreground color used for sorting, ornull if absent.

Return

Color|null — The foreground color.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSortOrder()

Returns the sort order.

Return

SortOrder — The sort order.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

isAscending()

Returns whether the sort order is ascending.

Return

Booleantrue if the sort order is ascending, orfalse otherwise.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.