Reorders actions within a definition

@param WorkflowDefinition|WorkflowAction $objects The objects to be reordered
@param array $newOrder An array of IDs of the actions in the order they should be.
324297
public function reorder($objects, $newOrder)
    {
        $sortVals = array_values($objects->map('ID', 'Sort')->toArray());
        sort($sortVals);

        // save the new ID values - but only use existing sort values to prevent
        // conflicts with items not in the table
        foreach ($newOrder as $key => $id) {
            if (!$id) {
                continue;
            }
            $object = $objects->find('ID', $id);
            $object->Sort = $sortVals[$key];
            $object->write();
        }
    }
739079
public function generateOrder($sortBy, $sortOrder, &$order)
    {
        if (! empty($sortBy)) {
            if (empty($sortOrder)) { // @codeCoverageIgnore
                $sortOrder = "ASC"; // @codeCoverageIgnore
            } // @codeCoverageIgnore

            $order = "$sortBy $sortOrder";
        }
    }
77280
public function fireAfterPersist(PersistenceContext $context, array $objects, array $rows)
    {
        if ($this->orderPropertyName) {
            $orderColumn = $this->orderColumn->getName();

            foreach ($objects as $key => $object) {
                $object->hydrate([
                        $this->orderPropertyName => $rows[$key]->getColumn($orderColumn)
                ]);
            }
        }
    }
1313569
protected function checkAllScheduledByAction(array $objects, $action): void
    {
        foreach ($objects as $object) {
            $this->postResetPermissions[] = $object;

            if ('delete' !== $action) {
                $this->getObjectFilter()->restore($object);
            }
        }
    }
270072
public function set_sortorder($sortorder) {
        $oldorder = $this->file_record->sortorder;
        $filerecord = new stdClass;
        $filerecord->sortorder = $sortorder;
        $this->update($filerecord);
        if (!$this->is_directory()) {
            // Callback for file sort order change.
            if ($pluginsfunction = get_plugins_with_function('after_file_sorted')) {
                foreach ($pluginsfunction as $plugintype => $plugins) {
                    foreach ($plugins as $pluginfunction) {
                        $pluginfunction($this->file_record, $oldorder, $sortorder);
                    }
                }
            }
        }
    }
444011
public static function reorderExclusions($exclusions) {
    $new_exclusions = [];
    foreach ($exclusions as $exclusion) {
      $from = strtotime($exclusion['from']);
      $new_exclusions[$from] = $exclusion;
    }
    sort($new_exclusions);

    return $new_exclusions;
  }
82871
public void addOrder(Order... orders) {
		if(null != this.orders){
			ArrayUtil.append(this.orders, orders);
		}
		this.orders = orders;
	}
1300471
public function addOrders(array $orders)
    {
        foreach ($orders as $key => $order) {
            $this->addOrder($order);

            /** Name the expression if $key is a non-numeric string. */
            if (is_string($key) && !is_numeric($key)) {
                $order = end($this->orders);
                $order->setName($key);
            }
        }

        return $this;
    }
312721
public function reorder(array $data)
    {
        $left = 1;
        foreach ($data as $root) {
            $left = $this->recursiveReorder($root, null, $left);
        }
    }
359781
protected function _reorder()
    {
        if (!empty($this->request->data['regions'])) {
            foreach ($this->request->data['regions'] as $theme => $regions) {
                foreach ($regions as $region => $ids) {
                    $ordering = 0;
                    foreach ($ids as $id) {
                        $blockRegion = $this->Blocks
                            ->BlockRegions
                            ->newEntity([
                                'id' => $id,
                                'theme' => $theme,
                                'region' => $region,
                                'ordering' => $ordering
                            ]);
                        $blockRegion->isNew(false);
                        $this->Blocks->BlockRegions->save($blockRegion);
                        $ordering++;
                    }
                }
            }

            return true;
        }

        return false;
    }
711634
public static function order($rows, $cls = 'saveoder', $task = 'saveorder')
	{
		return Builder\Grid::order($rows, $cls, $task);
	}
279775
protected function init(EntryToObjectsService $entryToObjectsService, WorkflowService $workflowService)
    {
        $this->setEntryToObjectsService($entryToObjectsService);
        $this->setWorkflowService($workflowService);
    }
515507
function order($new = null)
    {
        if (isset($new) && ($this->_attributes['order'] != $new)){
            $this->change('order', (int)$new);
        }
        return $this->_attributes['order'];
    }
738574
public function handleReorder(ReorderEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof PageBehavior) {
            return;
        }

        $propertyName = $this->propertyEncoder->systemName(static::FIELD);
        $parentNode = $this->documentInspector->getNode($document->getParent());

        $page = 1;
        foreach ($parentNode->getNodes() as $childNode) {
            $child = $this->documentManager->find($childNode->getIdentifier(), $event->getLocale());
            if (!$child instanceof PageBehavior) {
                continue;
            }

            $childNode->setProperty($propertyName, ++$page);
            $child->setPageNumber($page);
        }
    }
987341
public function ordersCombine($order, $resultOrder, $technique = 'ours')
    {
        $techniques = ['ours', 'summ', 'theirs'];

        if (!count($order) || !count($resultOrder)) {
            throw new \InvalidArgumentException(
                'Parameters `order` & `resultOrder` must contains a data'
            );
        }

        if (!in_array($technique, $techniques)) {
            throw new \InvalidArgumentException(
                'Parameter `technique` must be on of ours|summ|theirs'
            );
        }

        /* @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            '/orders/combine',
            "POST",
            [
                'technique' => $technique,
                'order' => json_encode($order),
                'resultOrder' => json_encode($resultOrder)
            ]
        );
    }
674986
public function setAccessorOrder($order, array $customOrder = []): void
    {
        if (! \in_array($order, [self::ACCESSOR_ORDER_UNDEFINED, self::ACCESSOR_ORDER_ALPHABETICAL, self::ACCESSOR_ORDER_CUSTOM], true)) {
            throw new InvalidArgumentException(\sprintf('The accessor order "%s" is invalid.', $order));
        }

        foreach ($customOrder as $name) {
            if (! \is_string($name)) {
                throw new InvalidArgumentException(\sprintf('$customOrder is expected to be a list of strings, but got element of value %s.', \var_export($name, true)));
            }
        }

        $this->accessorOrder = $order;
        $this->customOrder = \array_flip($customOrder);
        $this->sortProperties();
    }
529530
public function setOrders($orders)
    {
        foreach ($orders as $order) {
            $this->orders[$order->id] = $order->expose();
        }
    }