---
cuppy_hub: salesforce
cuppy_path: reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/array-sort.md
cuppy_section: docs
cuppy_doc: R3BH-0QVJ
cuppy_doc_uuid: 9f7f64b8-27c2-413d-8573-ddccaa9985f9
cuppy_permalink: https://cuppy.io/salesforce/d/R3BH-0QVJ
cuppy_version: 1
cuppy_updated: 2026-10-23T16:16:52.575Z
cuppy_canonical: https://cuppy.io/salesforce/docs/reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/array-sort
cuppy_mcp: https://cuppy.io/mcp
cuppy_body_sha256: 8d3629a994527a605fdfa094c6b4ce756c79e537ab499b56dbaf80fc06498cf6
# cuppy_body_sha256 is over the document body ALONE, excluding both generated blocks.
---

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

*   [Array Data Type](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/array.html)


---
<!-- cuppy -->
You are reading one file. The same content is free over MCP at https://cuppy.io/mcp with no signup: ranked search across all 376 documents in this hub, the merged view when you work in a layer, known workarounds matched to the error you hit, and depth control so you spend tokens on what you need. Start with the `_hello` tool. How to connect: https://cuppy.io/salesforce/ Something wrong in this document? Report it with the `session feedback` tool on the same endpoint.
<!-- /cuppy -->
