A function to sort modules by name.

Languages have a "sortable" name, so that "British English" sorts as "English, British".
This provides a more natural order in the language menu.

@return Closure
556440
private function moduleSorter(): Closure
    {
        return static function (ModuleInterface $x, ModuleInterface $y): int {
            $title1 = $x instanceof ModuleLanguageInterface ? $x->locale()->endonymSortable() : $x->title();
            $title2 = $y instanceof ModuleLanguageInterface ? $y->locale()->endonymSortable() : $y->title();

            return I18N::strcasecmp($title1, $title2);
        };
    }
1239031
function sortCustomKey(callable $closure) {
        $args = $this->baseStorageArgs;
        $args[] = parent::sortCustomKey($closure)->all();
        
        return (new static(...$args));
    }
718711
public function sort()
    {
        usort($this->set, function ($first, $second) {
            $ids = strcmp($first['id'], $second['id']);
            if ($ids === 0) {
                if ($first['context'] === null && $second['context'] === null) {
                    return 0;
                } else if ($first['context'] === null) {
                    return -1;
                } else if ($second['context'] === null) {
                    return 1;
                } else {
                    return strcmp($first['context'], $second['context']);
                }
            } else {
                return $ids;
            }
        });
    }
1090513
def sort_languages(self, order=Qt.AscendingOrder):
        

        self.beginResetModel()
        self.__languages = sorted(self.__languages, key=lambda x: (x.name), reverse=order)
        self.endResetModel()
782858
protected function get_module_name() {
        if (isset(self::$modulename)) {
            return self::$modulename;
        }
        self::$modulename = get_string('modulename', 'assign');
        return self::$modulename;
    }
376590
protected function cleanPosition()
    {
        $modulesType = [];

        $this->moduleQuery->clear();
        $modules = $this->moduleQuery->orderByPosition(Criteria::ASC);

        /** @var \Thelia\Model\Module $module */
        foreach ($modules as $module) {
            if (!isset($modulesType[$module->getType()])) {
                $modulesType[$module->getType()] = 0;
            }

            $module
                ->setPosition(++$modulesType[$module->getType()])
                ->save()
            ;
        }

        return $modulesType;
    }
757610
protected function _sortLanguagesCallback($oLang1, $oLang2)
    {
        $sSortParam = $this->_sDefSortField;
        $sVal1 = is_string($oLang1->$sSortParam) ? strtolower($oLang1->$sSortParam) : $oLang1->$sSortParam;
        $sVal2 = is_string($oLang2->$sSortParam) ? strtolower($oLang2->$sSortParam) : $oLang2->$sSortParam;

        if ($this->_sDefSortOrder == 'asc') {
            return ($sVal1 < $sVal2) ? -1 : 1;
        } else {
            return ($sVal1 > $sVal2) ? -1 : 1;
        }
    }
593688
function initSortMethod() {
        var sortMethod = PreferencesManager.getViewState(_WORKING_SET_SORT_PREF);

        if (!sortMethod) {
            sortMethod = _convertSortPref(PreferencesManager.getViewState(_LEGACY_SORT_PREF));
        }

        if (!sortMethod) {
            sortMethod = Commands.CMD_WORKINGSET_SORT_BY_ADDED;
        }
        return sortMethod;
    }
1015571
private function sort()
    {
        if (!$this->sorted) {
            $this->sorted = true;
            return usort($this->requestRates, function (array $requestRateA, array $requestRateB) {
                // PHP 7: Switch to the <=> "Spaceship" operator
                return $requestRateB['rate'] > $requestRateA['rate'];
            });
        }
        return $this->sorted;
    }
709164
public function sortByEndDate()
	{
		uksort( $this->contexts, function( $a, $b ) use ( &$contexts )
		{
			return -1 * strcmp( $this->contexts[ $a] ['period']['endDate'], $this->contexts[ $b]['period']['endDate'] );
		} );

		return $this;
	}
706177
public function isSortable() 
    {
        $this->getSearchCriteria();
        $sortable = new \stdClass;
        if($this->searchModel->Menu_id > 0) {
            $sortable->sortable = true;
            $sortable->link = Url::toRoute(['sort', 'Menu_id' => $this->searchModel->Menu_id]);
        } else {
            $sortable->sortable = false;
            $sortable->message = 'Filter on a menu first';
        }
        return $sortable;
    }
539748
public function sortAsc()
    {
        $cmp = function (TagInterface $a, TagInterface $b) {
            if ($a->getName() == $b->getName()) {
                return 0;
            }

            return ($a->getName() < $b->getName()) ? -1 : 1;
        };
        usort($this->elements, $cmp);
    }
262677
private function getBrowserLanguageOrDefault()
    {
        if ($browserLanguage = getenv('HTTP_ACCEPT_LANGUAGE')) {
            $browserLocale = substr($browserLanguage, 0, 2);
            if (in_array($browserLocale, TypiCMS::enabledLocales())) {
                return $browserLocale;
            }
        }

        return config('app.locale');
    }
1278655
function(items) {
        return items.sort(function(a, b) {
            return a.title.localeCompare(b.title);
        });
    }
395890
public function sort()
    {
        array_multisort(array_map(function ($pair) {
            return mb_convert_encoding($pair[0], 'UTF-16BE', 'UTF-8');
        }, $this->list), SORT_STRING, range(1, count($this->list)), $this->list);
    }
673903
function sortByOrdinal(extensions, done) {
    const sorted = extensions.sort((a, b) => {
        if (a.ordinal || b.ordinal) {
            if (!a.ordinal) return 1;
            if (!b.ordinal) return -1;
            if (a.ordinal < b.ordinal) return -1;
            return 1;
        }
        return a.pluginId.localeCompare(b.pluginId);
    });

    if (done) {
        done(sorted);
    }

    return sorted;
}
886160
public function sort(callable $closure)
    {
        $entities = $this->_entities;
        usort($entities, $closure);

        $sorted = new Entities();
        foreach ($entities as $entity) {
            $sorted->add($entity);
        }
        return $sorted;
    }