protected function sortManyManyThroughRelation(
        ManyManyThroughList $relation,
        array $idList,
        array $rawList,
        $sortColumn
    ) {
        $relation->getForeignID();
        $dataQuery = $relation->dataQuery();
        $manipulators = $dataQuery->getDataQueryManipulators();
        $manyManyManipulator = null;
        foreach ($manipulators as $manipulator) {
            if ($manipulator instanceof ManyManyThroughQueryManipulator) {
                $manyManyManipulator = $manipulator;
                break;
            }
        }

        if (!$manyManyManipulator) {
            throw new \LogicException('No ManyManyThroughQueryManipulator found');
        }

        $joinClass = $manyManyManipulator->getJoinClass();
        $ownerIDField = $manyManyManipulator->getForeignKey();
        $fileIdField = $manyManyManipulator->getLocalKey();

        $sort = 0;
        foreach ($rawList as $id) {
            if (in_array($id, $idList)) {
                $fileRecord = DataList::create($joinClass)->filter([
                    $ownerIDField => $relation->getForeignID(),
                    $fileIdField  => $id
                ])->first();

                if ($fileRecord) {
                    $fileRecord->setField($sortColumn, $sort++);
                    $fileRecord->write();
                }
            }
        }
    }