PHPackages                             senseexception/intl-sort - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. senseexception/intl-sort

ActiveLibrary[Localization &amp; i18n](/categories/localization)

senseexception/intl-sort
========================

A wrapper library for PHP Intl to sort values based on rules of locales

3.0.0(1y ago)43.4k11MITPHPPHP ^8.2CI passing

Since Apr 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/SenseException/intl-sort)[ Packagist](https://packagist.org/packages/senseexception/intl-sort)[ RSS](/packages/senseexception-intl-sort/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (8)Versions (12)Used By (1)

intl-sort
=========

[](#intl-sort)

A wrapper library for PHP Intl to sort values/objects based on rules of locales.

This library wraps the Collator class of the PHP Intl extension and offers a more fluid API without constant juggling for you to sort your values or objects by country/locale specific standards.

[![Latest Stable Version](https://camo.githubusercontent.com/a7d6c7f3eb96bbb42a0a744b8a52ac9c2e409ea6e732319ab8164168aa553838/68747470733a2f2f706f7365722e707567782e6f72672f73656e7365657863657074696f6e2f696e746c2d736f72742f762f737461626c65)](https://packagist.org/packages/senseexception/intl-sort)[![PHP from Packagist](https://camo.githubusercontent.com/c2cbdea6324a0caf090e4ddef1fd7c2c1d58cd11fccdae5898550e898096518e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73656e7365657863657074696f6e2f696e746c2d736f72742e737667)](https://packagist.org/packages/senseexception/intl-sort)[![Tests](https://github.com/SenseException/intl-sort/workflows/Tests/badge.svg)](https://github.com/SenseException/intl-sort/workflows/Tests/badge.svg)[![Static Analysis](https://github.com/SenseException/intl-sort/workflows/Static%20Analysis/badge.svg)](https://github.com/SenseException/intl-sort/workflows/Static%20Analysis/badge.svg)[![License](https://camo.githubusercontent.com/3c37737e8492f501ee466631d452b4bc863b6ac64967489351f1d2da9918d426/68747470733a2f2f706f7365722e707567782e6f72672f73656e7365657863657074696f6e2f696e746c2d736f72742f6c6963656e7365)](https://packagist.org/packages/senseexception/intl-sort)

### Why using this library?

[](#why-using-this-library)

PHP functions like `sort()` work most of the time when it comes to sort values, but they don't return useful results when a country or language specific order of values is needed like e.g. words with umlauts or other accents.

This library wraps the `Collator` class of the PHP Intl extension and offers a builder pattern API to create a `Sorter` to sort values or value objects by the rules of a locale. You also can implement your own sorting logic.

Installation
------------

[](#installation)

You can install this with [Composer](https://getcomposer.org/).

```
composer require senseexception/intl-sort

```

### Documentation

[](#documentation)

Read more about what this library is capable of in the [documentation](https://senseexception.github.io/intl-sort).

### Examples

[](#examples)

While PHP's own sort functions don't order the elements in a way that is expected in different countries, intl-sort will sort them with the help of the Intl-extension appropriate for the countries in your international project.

#### Ascending order

[](#ascending-order)

```
$sortBuilder = new \Budgegeria\IntlSort\Builder('de_DE');
$sorter = $sortBuilder->getSorter();

$sortedArray = $sorter->sort(['a', 'g', 'A', 'ß', 'ä', 'j', 'z']);

var_dump($sortedArray); // [0 => 'a', 2 => 'A', 4 => 'ä', 1 => 'g', 5 => 'j', 3 => 'ß', 6 => 'z'];
```

#### Descending order

[](#descending-order)

```
$sortBuilder = new \Budgegeria\IntlSort\Builder('de_DE');
$sorter = $sortBuilder->orderByDesc()->getSorter();

$sortedArray = $sorter->sort(['a', 'g', 'A', 'ß', 'ä', 'j', 'z']);

var_dump($sortedArray); // [0 => 'z', 1 => 'ß', 2 => 'j', 3 => 'g', 4 => 'ä', 5 => 'A', 6 => 'a',];
```

#### Order by keys

[](#order-by-keys)

```
$sortBuilder = new \Budgegeria\IntlSort\Builder('de_DE');
$sorter = $sortBuilder->orderByKeys()->getSorter();

$sortedArray = $sorter->sort(['g' => 1, 'A' => 2, 'ß' => 3, 'ä' => 4, 'z' => 5]);

var_dump($sortedArray); // ['A' => 2, 'ä' => 4, 'g' => 1, 'ß' => 3, 'z' => 5];
```

```
$sortBuilder = new \Budgegeria\IntlSort\Builder('de_DE');
$sorter = $sortBuilder->orderByKeys()->orderByDesc()->getSorter();

$sortedArray = $sorter->sort(['g' => 1, 'A' => 2, 'ß' => 3, 'ä' => 4, 'z' => 5]);

var_dump($sortedArray); // ['z' => 5, 'ß' => 3, 'g' => 1, 'ä' => 4, 'A' => 2,];
```

There are also more configuration possibilities in the builder like setting strength, lower case first / upper case first or special french collation.

Does it affect [GDPR](https://www.eugdpr.org/) somehow?
-------------------------------------------------------

[](#does-it-affect-gdpr-somehow)

intl-sort itself uses the locale only for the purposes to sort values with the help of the PHP Intl extension.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance65

Regular maintenance activity

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 97.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~186 days

Recently: every ~229 days

Total

9

Last Release

709d ago

Major Versions

1.x-dev → 2.0.02022-10-13

2.x-dev → 3.0.02024-05-30

PHP version history (4 changes)1.0.0PHP ^7.3

1.1.1PHP ^7.3 || ^8.0

2.0.0PHP ^8.0

3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1313ebcff68bc6cca3b8a1921c3ba13f83351212f707c15a5506880371371c47?d=identicon)[SenseException](/maintainers/SenseException)

---

Top Contributors

[![SenseException](https://avatars.githubusercontent.com/u/859964?v=4)](https://github.com/SenseException "SenseException (214 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

intlinternationalizationi18nicusortsorterorderCollator

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/senseexception-intl-sort/health.svg)

```
[![Health](https://phpackages.com/badges/senseexception-intl-sort/health.svg)](https://phpackages.com/packages/senseexception-intl-sort)
```

###  Alternatives

[symfony/intl

Provides access to the localization data of the ICU library

2.6k199.8M1.1k](/packages/symfony-intl)[aplus/language

Aplus Framework Language Library

2351.7M15](/packages/aplus-language)[aura/intl

The Aura Intl package provides internationalization tools, specifically message translation.

898.3M4](/packages/aura-intl)[skillshare/formatphp

Internationalize PHP apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.

8029.6k](/packages/skillshare-formatphp)[senseexception/intl-format

A wrapper library for PHP to format and internationalize values in messages like sprintf

123.2k2](/packages/senseexception-intl-format)[delight-im/i18n

Internationalization and localization for PHP

625.2k3](/packages/delight-im-i18n)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
