src/records/SortableTrait.php
protected function saveNewOrder(
        array $sortOrder,
        string $targetAttribute,
        array $sortOrderCondition = [],
        string $sortOrderAttribute = 'sortOrder'
    ): bool {
        foreach ($sortOrder as $target => $order) {
            Craft::$app->getDb()->createCommand()
                ->update(
                    static::tableName(),
                    [$sortOrderAttribute => $order],
                    array_merge(
                        $sortOrderCondition,
                        [
                            $targetAttribute => $target
                        ]
                    )
                )
                ->execute();
        }

        return true;
    }
protected function saveNewOrder(
        array $sortOrder,
        string $targetAttribute,
        array $sortOrderCondition = [],
        string $sortOrderAttribute = 'sortOrder'
    ): bool {
        foreach ($sortOrder as $target => $order) {
            Craft::$app->getDb()->createCommand()
                ->update(
                    static::tableName(),
                    [$sortOrderAttribute => $order],
                    array_merge(
                        $sortOrderCondition,
                        [
                            $targetAttribute => $target
                        ]
                    )
                )
                ->execute();
        }

        return true;
    }
protected function saveNewOrder ( array $ sortOrder , string $ targetAttribute , array $ sortOrderCondition = [ ] , string $ sortOrderAttribute = 'sortOrder' ) : bool { foreach ( $ sortOrder as $ target => $ order ) { Craft :: $ app -> getDb ( ) -> createCommand ( ) -> update ( static :: tableName ( ) , [ $ sortOrderAttribute => $ order ] , array_merge ( $ sortOrderCondition , [ $ targetAttribute => $ target ] ) ) -> execute ( ) ; } return true ; }
Saves a new sort order.

@param array $sortOrder The new sort order that needs to be saved.  The 'key' represents the target value and
the 'value' represent the sort order.
@param string $targetAttribute The target attribute that the new order is keyed on.
@param array $sortOrderCondition Additional condition params used to accurately identify the sort order that
need to be changed.  For example, some sort orders may be site specific, therefore passing a 'siteId' condition
would only apply the re-ordering to the specified site.
@param string $sortOrderAttribute The sort order attribute that needs to be updated
@return bool
@throws \yii\db\Exception
Saves a new sort order .