ActiveDataProvider and union sorting ordering

Hi,
I have a union of 2 tables
$tableA->union($tableB, true);

If I do sorting like this:
$dataProvider->sort->attributes[‘id’] = [
‘asc’ => [‘id’ => SORT_ASC],
‘desc’ => [‘id’ => SORT_DESC],
];

It applies it to the first table only and all the results from the second table are always at the end.

Is there any way to fix this?