PHPackages                             tsoffereins/number-sorter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tsoffereins/number-sorter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tsoffereins/number-sorter
=========================

A PHP library that helps you sort your numbers alphabetically.

v1.0.0(7y ago)08MITPHPPHP &gt;=5.6

Since Apr 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/tsoffereins/number-sorter)[ Packagist](https://packagist.org/packages/tsoffereins/number-sorter)[ Docs](https://github.com/tsoffereins/number-sorter)[ RSS](/packages/tsoffereins-number-sorter/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Number sorter
=============

[](#number-sorter)

With this library you can finally sort your list of numbers the way you always wanted: alphabetically.

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

[](#installation)

You can install the NumberSorter through [composer](https://packagist.org/packages/tsoffereins/number-sorter):

```
composer require tsoffereins/number-sorter
```

This library requires **PHP 5.6 or higher** in order to work.

Usage
-----

[](#usage)

Sorting a list of number alphabetically is easy as 1 3 2:

```
$sorter = new \NumberSorter\NumberSorter();

$input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

$output = $sorter->sort($input);

var_dump($output); // [8, 5, 4, 9, 1, 7, 6, 10, 3, 2]
```

### Numeric list

[](#numeric-list)

The input list must be an array of only numeric values. This includes any value that would make `is_numeric()`return true. See [php.net](https://www.php.net/manual/en/function.is-numeric.php) for more on that.

If you pass a non numeric value a `TypeError` will be thrown.

### Language

[](#language)

By default numbers are sorted alphabetically in English, but if you'd like to sort in another language you can pass it to the constructor:

```
$sorter = new \NumberSorter\NumberSorter('nl');

$input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

$output = $sorter->sort($input);

var_dump($output); // [8, 3, 1, 9, 10, 2, 4, 5, 6, 7]
```

The NumberSorter library relies on the package `kwn/number-to-words` for translating numbers into words. Take a look at their documentation for the [available locales](https://github.com/kwn/number-to-words#available-locale).

### Immutability

[](#immutability)

Passing an array by reference and sorting its contents, like PHP's `sort()` function does, might have been OK in the nineties, but proper code should limit side effects. Therefore, the NumberSorter does not alter the input array but returns a new array with the same numbers sorted alphabetically.

Support
-------

[](#support)

Are you kidding me?!

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2595d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b9b0e2f4323a09170afd33bc776b3137d64d08282171224a4684ff49b5175f6?d=identicon)[tsoffereins](/maintainers/tsoffereins)

---

Top Contributors

[![tsoffereins](https://avatars.githubusercontent.com/u/4030108?v=4)](https://github.com/tsoffereins "tsoffereins (1 commits)")

---

Tags

sortnumberalphabetically

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tsoffereins-number-sorter/health.svg)

```
[![Health](https://phpackages.com/badges/tsoffereins-number-sorter/health.svg)](https://phpackages.com/packages/tsoffereins-number-sorter)
```

###  Alternatives

[kyslik/column-sortable

Package for handling column sorting in Laravel 6.x

6485.6M21](/packages/kyslik-column-sortable)[mottie/tablesorter

tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.

2.6k223.5k](/packages/mottie-tablesorter)[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4235.0M21](/packages/kwn-number-to-words)[icecave/parity

A customizable deep comparison library.

516.8M10](/packages/icecave-parity)[symbiote/silverstripe-gridfieldextensions

A collection of useful grid field components

971.8M235](/packages/symbiote-silverstripe-gridfieldextensions)[undefinedoffset/sortablegridfield

Adds drag and drop functionality to Silverstripe's GridField

941.2M50](/packages/undefinedoffset-sortablegridfield)

PHPackages © 2026

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