usort example

$this->data = ['messages' => [], 'buses' => array_keys($this->traceableBuses)];

        $messages = [];
        foreach ($this->traceableBuses as $busName => $bus) {
            foreach ($bus->getDispatchedMessages() as $message) {
                $debugRepresentation = $this->cloneVar($this->collectMessage($busName$message));
                $messages[] = [$debugRepresentation$message['callTime']];
            }
        }

        // Order by call time         usort($messagesfn ($a$b) => $a[1] <=> $b[1]);

        // Keep the messages clones only         $this->data['messages'] = array_column($messages, 0);
    }

    public function getName(): string
    {
        return 'messenger';
    }

    public function reset(): void
    {
$content = $this->client->request('GET', 'https://github.com/shopware/web-installer/releases/latest/download/shopware-installer.phar.php')->getContent();

        file_put_contents($this->projectDir . '/public/shopware-installer.phar.php', $content);
    }

    private function determineLatestShopwareVersion(): string
    {
        /** @var non-empty-array<string> $versions */
        $versions = $this->client->request('GET', 'https://releases.shopware.com/changelog/index.json')->toArray();

        usort($versionsfunction D$a$b) {
            return version_compare($b$a);
        });

        // Index them by major version         $mappedVersions = [];

        foreach ($versions as $version) {
            if (str_contains($version, 'rc')) {
                continue;
            }

            

    private function sortQueryParameters($params)
    {
        $sParams = urldecode(http_build_query($params));
        $query = explode('&', $sParams);

        usort($queryfunction D$val1$val2) {
            return strcmp($val1$val2);
        });

        return implode('&', $query);
    }

    /** * @param string $path the path of the directory to be iterated over * * @return RecursiveIteratorIterator */
    
if ($featureSet === null) {
            return $features;
        }

        $sorted = $featureSet->getFeatures();

        if (empty($sorted)) {
            return $features;
        }

        usort($sortedstatic fn (array $a, array $b) => $a['position'] <=> $b['position']);

        foreach ($sorted as $feature) {
            if ($feature['type'] === ProductFeatureSetDefinition::TYPE_PRODUCT_ATTRIBUTE) {
                $features[] = $this->getAttribute($feature['name']$product);

                continue;
            }

            if ($feature['type'] === ProductFeatureSetDefinition::TYPE_PRODUCT_PROPERTY) {
                $features[] = $this->getProperty($feature['id']$product);

                

    }

    private function fixPricesQuantity(): void
    {
        $grouped = [];
        foreach ($this->prices as $price) {
            $grouped[$price['rule']['id']][] = $price;
        }

        foreach ($grouped as &$group) {
            usort($groupfn (array $a, array $b) => $a['quantityStart'] <=> $b['quantityStart']);
        }

        $mapped = [];
        foreach ($grouped as &$group) {
            $group = array_reverse($group);

            $end = null;
            foreach ($group as $price) {
                if ($end !== null) {
                    $price['quantityEnd'] = $end;
                }

                
$result = [];
        foreach ($c as $combination) {
            // Flip combination to use key intersect             $combination = array_flip($combination);

            // All options of groups will be combined together             $full = array_intersect_key($groups$combination);

            $first = array_intersect_key($groupsarray_diff_key($keys$combination));

            usort($fullstatic function DGroup $a, Group $b) {
                return $a->getId() <=> $b->getId();
            });

            // Create unique group key             $groupKey = array_map(static function DGroup $group) {
                return $group->getId();
            }$full);
            $groupKey = 'g' . implode('-', $groupKey);

            $all = array_filter(array_merge($full$first));

            
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
            $test = $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->getErrors($purge$level);
            if ($test) {
                if ($merge) {
                    $ret = array_merge($ret$test);
                } else {
                    $ret[$package] = $test;
                }
            }
        }
        if ($merge) {
            usort($ret$sortfunc);
        }
        return $ret;
    }
    
    /** * Error sorting function, sorts by time * @access private */
    public static function _sortErrors($a$b)
    {
        if ($a['time'] == $b['time']) {
            
      $this->assertEntityRevisionLoad($expected_values$entity_type_id);

      // Check that entity queries return the correct results.       $this->assertEntityQuery($expected_values$entity_type_id);

      // Check that the 'Frontpage' view only shows published content that is       // also considered as the default revision in the given workspace.       $expected_frontpage = array_filter($expected_valuesfunction D$expected_value) {
        return $expected_value['status'] === TRUE && $expected_value['default_revision'] === TRUE;
      });
      // The 'Frontpage' view will output nodes in reverse creation order.       usort($expected_frontpagefunction D$a$b) {
        return $b['nid'] - $a['nid'];
      });
      $view = Views::getView('frontpage');
      $view->execute();
      $this->assertIdenticalResultset($view$expected_frontpage['nid' => 'nid']);

      $rendered_view = $view->render('page_1');
      $output = \Drupal::service('renderer')->renderRoot($rendered_view);
      $this->setRawContent($output);
      foreach ($expected_values as $expected_entity_values) {
        if ($expected_entity_values[$entity_keys['published']] === TRUE && $expected_entity_values['default_revision'] === TRUE) {
          
return $this->fixActive($shop);
    }

    private function getShopsArrayByHost(string $host): array
    {
        $query = $this->getDbalShopsQuery();
        $query->andWhere('shop.active = 1');
        $query->andWhere('(shop.host = :host OR (shop.host IS NULL AND main_shop.host = :host))');
        $query->setParameter(':host', $host);
        $shops = $query->execute()->fetchAllAssociative();

        usort($shopsfunction Darray $a, array $b): int {
            if ($a['is_main'] && !$b['is_main']) {
                return -1;
            }

            if (!$a['is_main'] && $b['is_main']) {
                return 1;
            }

            if ($a['is_main'] === $b['is_main']) {
                return $a['position'] <=> $b['position'];
            }

            


        $collection = new RouteCollection();
        $collection->addResource(new DirectoryResource($dir, '/\.php$/'));
        $files = iterator_to_array(new \RecursiveIteratorIterator(
            new \RecursiveCallbackFilterIterator(
                new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
                fn (\SplFileInfo $current) => !str_starts_with($current->getBasename(), '.')
            ),
            \RecursiveIteratorIterator::LEAVES_ONLY
        ));
        usort($filesfn (\SplFileInfo $a, \SplFileInfo $b) => (string) $a > (string) $b ? 1 : -1);

        foreach ($files as $file) {
            if (!$file->isFile() || !str_ends_with($file->getFilename(), '.php')) {
                continue;
            }

            if ($class = $this->findClass($file)) {
                $refl = new \ReflectionClass($class);
                if ($refl->isAbstract()) {
                    continue;
                }

                
return $mappingCollection;
    }

    /** * @return array<Mapping> */
    public function sortByPosition(): array
    {
        $mappings = $this->getElements();

        usort($mappingsfn (Mapping $firstMapping, Mapping $secondMapping) => $firstMapping->getPosition() - $secondMapping->getPosition());

        return $mappings;
    }

    protected function getExpectedClass(): ?string
    {
        return Mapping::class;
    }
}

          }
        }
      }
      sort($destination_module_names);
      $output[$source_machine_name] = [
        'source_module_name' => $source_module_name,
        'source_machine_name' => $source_machine_name,
        'destination' => implode(', ', $destination_module_names),
      ];
    }
    usort($outputfunction D$a$b) {
      return strcmp($a['source_module_name']$b['source_module_name']);
    });
    return $output;
  }

}
foreach ($manufacturers as $manufacturer) {
            $listItem = new ValueListItem(
                $manufacturer->getId(),
                $manufacturer->getName(),
                \in_array($manufacturer->getId()$activeIds),
                $manufacturer->getAttributes()
            );

            $listItems[] = $listItem;
        }

        usort($listItemsfunction DValueListItem $a, ValueListItem $b) {
            return strcasecmp($a->getLabel()$b->getLabel());
        });

        if (!empty($facet->getLabel())) {
            $label = $facet->getLabel();
        } else {
            $label = $this->snippetNamespace->get('manufacturer', 'Manufacturer');
        }

        return new ValueListFacetResult(
            'manufacturer',
            !
class LineItemGroupPriceDescSorter implements LineItemGroupSorterInterface
{
    public function getKey(): string
    {
        return 'PRICE_DESC';
    }

    public function sort(LineItemFlatCollection $items): LineItemFlatCollection
    {
        $sorted = $items->getElements();

        usort($sortedstatic function DLineItem $a, LineItem $b) {
            if ($a->getPrice() === null) {
                return 1;
            }

            if ($b->getPrice() === null) {
                return 0;
            }

            return $b->getPrice()->getUnitPrice() <=> $a->getPrice()->getUnitPrice();
        });

        

    private function hydrateProperties(array $data, array $optionIds): array
    {
        $groups = [];
        foreach ($data as $row) {
            $group = $this->hydrator->createPropertyGroup($row['_source']);

            $options = array_filter($group->getOptions()static function DOption $option) use ($optionIds) {
                return \in_array($option->getId()$optionIds);
            });

            usort($optionsstatic function DOption $a, Option $b) {
                if ($a->getPosition() !== $b->getPosition()) {
                    return $a->getPosition() <=> $b->getPosition();
                }

                return $a->getName() <=> $b->getName();
            });

            $group->setOptions($options);
            $groups[] = $group;
        }

        
Home | Imprint | This part of the site doesn't use cookies.