> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Ordena as séries temporais por timestamp em ordem crescente.

# timeSeriesGroupArray

<div id="timeSeriesGroupArray">
  ## timeSeriesGroupArray
</div>

Introduzido em: v25.8.0

Ordena os dados de séries temporais por timestamp em ordem crescente.

<Note>
  Esta função é experimental; habilite-a definindo `allow_experimental_ts_to_grid_aggregate_function=true`.
</Note>

**Sintaxe**

```sql theme={null}
timeSeriesGroupArray(timestamp, value)
```

**Argumentos**

* `timestamp` — O timestamp da amostra. [`DateTime`](/pt-BR/reference/data-types/datetime) ou [`UInt32`](/pt-BR/reference/data-types/int-uint) ou [`UInt64`](/pt-BR/reference/data-types/int-uint)
* `value` — Valor da série temporal correspondente ao timestamp. [`(U)Int*`](/pt-BR/reference/data-types/int-uint) ou [`Float*`](/pt-BR/reference/data-types/float) ou [`Decimal`](/pt-BR/reference/data-types/decimal)

**Valor retornado**

Retorna um array de tuplas `(timestamp, value)` ordenado por timestamp em ordem crescente. Se houver vários valores para o mesmo timestamp, a função escolherá o maior deles. [`Array(Tuple(T1, T2))`](/pt-BR/reference/data-types/array)

**Exemplos**

**Uso básico com valores individuais**

```sql title=Query theme={null}
WITH
    [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps,
    [1, 6, 8, 17, 19, 5]::Array(Float32) AS values
SELECT timeSeriesGroupArray(timestamp, value)
FROM
(
    SELECT
        arrayJoin(arrayZip(timestamps, values)) AS ts_and_val,
        ts_and_val.1 AS timestamp,
        ts_and_val.2 AS value
);
```

```response title=Response theme={null}
┌─timeSeriesGroupArray(timestamp, value)───────────────┐
│ [(100, 5), (110, 1), (120, 6), (130, 8), (140, 19)]  │
└──────────────────────────────────────────────────────┘
```

**Enviando várias amostras de timestamps e valores como arrays do mesmo tamanho**

```sql title=Query theme={null}
WITH
    [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps,
    [1, 6, 8, 17, 19, 5]::Array(Float32) AS values
SELECT timeSeriesGroupArray(timestamps, values);
```

```response title=Response theme={null}
┌─timeSeriesGroupArray(timestamps, values)──────────────┐
│ [(100, 5), (110, 1), (120, 6), (130, 8), (140, 19)]   │
└───────────────────────────────────────────────────────┘
```
