Array functions

Introduced in: v1.1.0

Reverses the order of the elements in the input array or the characters in the input string.

**Syntax**

```
reverse(arr | str)
```

**Arguments**

- `arr | str` — The source array or string. [`Array(T)`](/docs/sql-reference/data-types/array) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an array or string with the order of elements or characters reversed.

**Examples**

**Reverse array**

```
SELECT reverse([1, 2, 3, 4]);
```

```
[4, 3, 2, 1]
```

**Reverse string**

```
SELECT reverse('abcd');
```

```
'dcba'
```

## Distance functions[​](#distance-functions "Direct link to Distance functions")

All supported functions are described in [distance functions documentation](/docs/sql-reference/functions/distance-functions).

- [array](#array)- [arrayAUCPR](#arrayAUCPR)- [arrayAll](#arrayAll)- [arrayAutocorrelation](#arrayAutocorrelation)- [arrayAvg](#arrayAvg)- [arrayCompact](#arrayCompact)- [arrayConcat](#arrayConcat)- [arrayCount](#arrayCount)- [arrayCumSum](#arrayCumSum)- [arrayCumSumNonNegative](#arrayCumSumNonNegative)- [arrayDifference](#arrayDifference)- [arrayDistinct](#arrayDistinct)- [arrayDotProduct](#arrayDotProduct)- [arrayElement](#arrayElement)- [arrayElementOrNull](#arrayElementOrNull)- [arrayEnumerate](#arrayEnumerate)- [arrayEnumerateDense](#arrayEnumerateDense)- [arrayEnumerateDenseRanked](#arrayEnumerateDenseRanked)- [arrayEnumerateUniq](#arrayEnumerateUniq)- [arrayEnumerateUniqRanked](#arrayEnumerateUniqRanked)- [arrayExcept](#arrayExcept)- [arrayExists](#arrayExists)- [arrayFill](#arrayFill)- [arrayFilter](#arrayFilter)- [arrayFirst](#arrayFirst)- [arrayFirstIndex](#arrayFirstIndex)- [arrayFirstOrNull](#arrayFirstOrNull)- [arrayFlatten](#arrayFlatten)- [arrayFold](#arrayFold)- [arrayIntersect](#arrayIntersect)- [arrayJaccardIndex](#arrayJaccardIndex)- [arrayJoin](#arrayJoin)- [arrayLast](#arrayLast)- [arrayLastIndex](#arrayLastIndex)- [arrayLastOrNull](#arrayLastOrNull)- [arrayLevenshteinDistance](#arrayLevenshteinDistance)- [arrayLevenshteinDistanceWeighted](#arrayLevenshteinDistanceWeighted)- [arrayMap](#arrayMap)- [arrayMax](#arrayMax)- [arrayMin](#arrayMin)- [arrayNormalizedGini](#arrayNormalizedGini)- [arrayPartialReverseSort](#arrayPartialReverseSort)- [arrayPartialShuffle](#arrayPartialShuffle)- [arrayPartialSort](#arrayPartialSort)- [arrayPopBack](#arrayPopBack)- [arrayPopFront](#arrayPopFront)- [arrayProduct](#arrayProduct)- [arrayPushBack](#arrayPushBack)- [arrayPushFront](#arrayPushFront)- [arrayROCAUC](#arrayROCAUC)- [arrayRandomSample](#arrayRandomSample)- [arrayReduce](#arrayReduce)- [arrayReduceInRanges](#arrayReduceInRanges)- [arrayRemove](#arrayRemove)- [arrayResize](#arrayResize)- [arrayReverse](#arrayReverse)- [arrayReverseFill](#arrayReverseFill)- [arrayReverseSort](#arrayReverseSort)- [arrayReverseSplit](#arrayReverseSplit)- [arrayRotateLeft](#arrayRotateLeft)- [arrayRotateRight](#arrayRotateRight)- [arrayShiftLeft](#arrayShiftLeft)- [arrayShiftRight](#arrayShiftRight)- [arrayShingles](#arrayShingles)- [arrayShuffle](#arrayShuffle)- [arraySimilarity](#arraySimilarity)- [arraySlice](#arraySlice)- [arraySort](#arraySort)- [arraySplit](#arraySplit)- [arraySum](#arraySum)- [arraySymmetricDifference](#arraySymmetricDifference)- [arrayTranspose](#arrayTranspose)- [arrayUnion](#arrayUnion)- [arrayUniq](#arrayUniq)- [arrayWithConstant](#arrayWithConstant)- [arrayZip](#arrayZip)- [arrayZipUnaligned](#arrayZipUnaligned)- [countEqual](#countEqual)- [empty](#empty)- [emptyArrayDate](#emptyArrayDate)- [emptyArrayDateTime](#emptyArrayDateTime)- [emptyArrayFloat32](#emptyArrayFloat32)- [emptyArrayFloat64](#emptyArrayFloat64)- [emptyArrayInt16](#emptyArrayInt16)- [emptyArrayInt32](#emptyArrayInt32)- [emptyArrayInt64](#emptyArrayInt64)- [emptyArrayInt8](#emptyArrayInt8)- [emptyArrayString](#emptyArrayString)- [emptyArrayToSingle](#emptyArrayToSingle)- [emptyArrayUInt16](#emptyArrayUInt16)- [emptyArrayUInt32](#emptyArrayUInt32)- [emptyArrayUInt64](#emptyArrayUInt64)- [emptyArrayUInt8](#emptyArrayUInt8)- [has](#has)- [hasAll](#hasAll)- [hasAny](#hasAny)- [hasSubstr](#hasSubstr)- [indexOf](#indexOf)- [indexOfAssumeSorted](#indexOfAssumeSorted)- [kql\_array\_sort\_asc](#kql_array_sort_asc)- [kql\_array\_sort\_desc](#kql_array_sort_desc)- [length](#length)- [notEmpty](#notEmpty)- [range](#range)- [replicate](#replicate)- [reverse](#reverse)- [Distance functions](#distance-functions)

Was this page helpful?