---
title: shuffle function
description: Learn the syntax of the shuffle function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/shuffle
---

# `shuffle` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns a random permutation of the array in `expr`.

## Syntax

```
shuffle(expr)
```

## Arguments

* `expr`: An `ARRAY` expression.

## Returns

The result type matches the type `expr`.

This function is non-deterministic.

## Examples

```sql
> SELECT shuffle(array(1, 20, 3, 5));
 [3,1,5,20]
> SELECT shuffle(array(1, 20, NULL, 3));
 [20,NULL,3,1]
```

## Related functions

* [`array_sort` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_sort.md)
* [`sort_array` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/sort_array.md)
