`ARRAY_SORT`

Data 360 Query Guide, mirrored from developer.salesforce.com: **Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

markdownreferencev1R3BH-0QVJguide: data-cloud-query-guidestage: referencetrust: officialsource: developer.salesforce.comservice: data360interface: sql`ARRAY_SORT`Data 360Data CloudData 360 Query Guide

Created 23 Oct 2026 · Modified 23 Oct 2026 · 1 version

Mirror of <https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/array-sort.html> (Salesforce, Data 360 Query Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.

ARRAY_SORT

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Sorts the elements of an array in ascending or descending order.

  • <input_array>: The array to sort.
  • ascending: A boolean flag that indicates the sort order. When true (default), sorts in ascending order. When false, sorts in descending order.

Returns an array with elements sorted in the specified order. NULL values are always first in the output array.

  • NULL values are always first in the output array, regardless of sort order.
  • The default sort order is ascending.

Sort an array in ascending order (default behavior).

Returns array[1, 1, 2, 3, 4, 5, 6, 9], sorted in ascending order.

Sort an array in descending order using the optional flag.

Returns array[9, 6, 5, 4, 3, 2, 1, 1], sorted in descending order.

Sort an array that contains NULL values.

Returns array[null, null, 1, 2, 3]. NULL values are first, followed by the sorted non-NULL values.

Read this document as markdown — the same bytes an agent receives.