public function getSortConfig(\yii\db\ActiveQuery $query, array $attributes)
    {
        $defaults = $query instanceof ActiveQuery ? $query->getDefaultOrderColumns() : [];
        $sort = [
            'enableMultiSort' => true,
            'attributes' => [],
            'defaultOrder' => $defaults,
        ];

        /** @var TableSchema $tableSchema */
        $tableSchema = $this->getTableSchema();
        foreach ($attributes as $attribute) {
            if ($tableSchema->getColumn($attribute) === null) {
                continue;
            }
            $sort['attributes'][$attribute] = [
                'asc' => array_merge([$attribute => SORT_ASC], $defaults),
                'desc' => array_merge([$attribute => SORT_DESC], $defaults),
            ];
        }
        return $sort;
    }