getContext(); $sortByPropertyPath = $arguments[0]; $sortOrder = 'DESC'; if (isset($arguments[1]) && !empty($arguments[1]) && in_array($arguments[1], array('ASC', 'DESC'))) { $sortOrder = $arguments[1]; } $sortedNodes = array(); $sortSequence = array(); $nodesByIdentifier = array(); /** @var Node $node */ foreach ($nodes as $node) { $propertyValue = $node->getProperty($sortByPropertyPath); if ($propertyValue instanceof \DateTime) { $propertyValue = $propertyValue->getTimestamp(); } $sortSequence[$node->getIdentifier()] = $propertyValue; $nodesByIdentifier[$node->getIdentifier()] = $node; } if ($sortOrder === 'DESC') { arsort($sortSequence); } else { asort($sortSequence); } foreach ($sortSequence as $nodeIdentifier => $value) { $sortedNodes[] = $nodesByIdentifier[$nodeIdentifier]; } $flowQuery->setContext($sortedNodes); } } }