Trouble sorting tables

Hello everyone one, I’m new to InfluxDB and Flux, and I’m having a hard time using union(columns: [“table1”,“table2”]) then sort(columns: ["_time"]).
I managed to unify 2 tables, but the rows doesn’t mix the data, it keeps like:
all data from table 1(sorted by time)
all data from table 2(sorted by time)
Instead of have the data mixed and sorted as one:

Anybody know what could be done to get the proper result?

Hello @Fabio_V,
Welcome!
This worked for me:

import "experimental/array"
data = array.from(rows: [{_measurement: "m0", mytag: "t0", _field: "f0", _value: "foo0", _time: 2020-11-01T00:00:00Z},
  {_measurement: "m0", mytag: "t0", _field: "f0", _value: "bar0", _time: 2020-11-04T00:00:00Z},
  {_measurement: "m1", mytag: "t0", _field: "f0", _value: "foo1", _time: 2020-11-03T00:00:00Z},
  {_measurement: "m1", mytag: "t0", _field: "f0", _value: "bar1", _time: 2020-11-05T00:00:00Z}])

t1 = data
  |> range(start: 2020-11-01T00:00:00Z)
  |> filter(fn: (r) => r._measurement == "m0")

t2 = data
  |> range(start: 2020-11-01T00:00:00Z)
  |> filter(fn: (r) => r._measurement == "m1")


union(tables: [t1, t2])
|> sort(columns: ["_time"], desc: false)
|> yield()

after exploring a bunch, I discovered that _measurement (my guess), was auto sorting the column, which kept them separated. When I used keep() function on the column i needed, sort() worked pretty well.