usort

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Sort an array by values using a user-defined comparison function
<?php usort(array &$array, callable $callback): true
<?php             $this->_conn->quote($tableName)

        ));



        usort(

            $indexArray,





            static function (array $a, array $b): int {

                if ($a['pk'] === $b['pk']) {

                    return $a['cid'] - $b['cid'];

                }



                return $a['pk'] - $b['pk'];

            }

        );



        foreach ($indexArray as $indexColumnRow) {

            if ($indexColumnRow['pk'] === 0 || $indexColumnRow['pk'] === '0') {
<?php     {

        $listing = $this->toArray();



        usort($listing, function (StorageAttributes $a, StorageAttributes $b) {

            return $a->path() <=> $b->path();

        });



        return new DirectoryListing($listing);

    }
<?php         if ($this->sort_by_score) {

            usort($clone, function ($a, $b) {

                if ($a['score'] > $b['score']) {

                    return -1;

                } elseif ($a['score'] < $b['score']) {

                    return 1;

                } else {

                    return 0;

                }

            });

        }
<?php         $arr = $this->all();



        usort($arr, function ($a, $b) use ($sorts) {

            foreach ($sorts as $sort) {

                $bits = explode(':', $sort);

                $sort_by = $bits[0];

                $sort_dir = array_get($bits, 1);



                [$one, $two] = $this->getSortableValues($sort_by, $a, $b);



                $result = Compare::values($one, $two);



                if ($result !== 0) {

                    return ($sort_dir === 'desc') ? $result * -1 : $result;

                }

            }



            return 0;

        });



        return new static($arr);

    }
<?php                 $installOrder[$op->getPackage()->getName()] = $index;

            }

        }

        usort($uninstallOperations, function ($a, $b) use ($installOrder) {

            return $installOrder[$b->getPackage()->getName()] - $installOrder[$a->getPackage()->getName()];

        });



        $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'reinstall', $input, $output);

        $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
<?php         if ($input->getOption('tree')) {

            $rootRequires = $this->getRootRequires();

            $packages = $installedRepo->getPackages();

            usort($packages, function (BasePackage $a, BasePackage $b) {

                return strcmp((string) $a, (string) $b);

            });

            $arrayTree = array();

            foreach ($packages as $package) {

                if (in_array($package->getName(), $rootRequires, true)) {
<?php         $packages = $this->groupLiteralsByName($pool, $literals);



        foreach ($packages as &$nameLiterals) {

            usort($nameLiterals, function ($a, $b) use ($pool, $requiredPackage) {

                return $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);

            });

        }



        foreach ($packages as &$sortedLiterals) {
<?php         $selected = \call_user_func_array('array_merge', array_values($packages));




        usort($selected, function ($a, $b) use ($pool, $requiredPackage) {

            return $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);

        });



        return $selected;

    }
<?php             }

        }



        usort($usedAliases, function ($a, $b) {

            return strcmp($a['package'], $b['package']);

        });



        return $usedAliases;

    }
<?php             && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())

        ) {

            $prevSource = $prevPackage->getInstallationSource();

            usort($sources, function ($a, $b) use ($prevSource) {

                return $a === $prevSource ? -1 : 1;

            });



            return $sources;

        }
<?php             return strcmp($a, $b);

        };

        usort($uninstalls, $sortByName);

        usort($installsUpdates, $sortByName);



        foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
<?php             return strcmp($a, $b);

        };

        usort($uninstalls, $sortByName);

        usort($installsUpdates, $sortByName);



        foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
<?php             $locked[] = $spec;

        }



        usort($locked, function ($a, $b) {

            $comparison = strcmp($a['name'], $b['name']);



            if (0 !== $comparison) {

                return $comparison;

            }




            return strcmp($a['version'], $b['version']);

        });



        return $locked;

    }
<?php             usort($branches, function ($a, $b) {

                $aRemote = 0 === strpos($a, 'remotes/');

                $bRemote = 0 === strpos($b, 'remotes/');



                if ($aRemote !== $bRemote) {

                    return $aRemote ? 1 : -1;

                }



                return strnatcasecmp($b, $a);

            });



            foreach ($branches as $candidate) {

                $candidateVersion = Preg::replace('{^remotes/\S+/}', '', $candidate);
<?php         }



        sort($data['dev-package-names']);

        usort($data['packages'], function ($a, $b) {

            return strcmp($a['name'], $b['name']);

        });



        $this->file->write($data);