PHPackages                             awssat/numbered-string-order - 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. awssat/numbered-string-order

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

awssat/numbered-string-order
============================

Sort a string array based on the included numbers naturally.

1.0.9(7y ago)7192[1 issues](https://github.com/awssat/numbered-string-order/issues)MITPHPPHP ~7.0

Since Nov 15Pushed 7y ago2 watchersCompare

[ Source](https://github.com/awssat/numbered-string-order)[ Packagist](https://packagist.org/packages/awssat/numbered-string-order)[ Docs](https://github.com/Awssat/numberedStringOrder)[ RSS](/packages/awssat-numbered-string-order/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (7)Dependencies (1)Versions (11)Used By (0)

numberedStringOrder
===================

[](#numberedstringorder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/233a9f1524125a8b70b147ab4dbebea220c971c83c114e93e1702c19489a59db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6177737361742f6e756d62657265642d737472696e672d6f726465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/awssat/numbered-string-order)[![StyleCI](https://camo.githubusercontent.com/24ab61112c60426ff64c963d989f0302dd04e8dcee9ef5ccb3731cb5a4ecb437/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131303736343835372f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/110764857)[![Build Status](https://camo.githubusercontent.com/3636ff7a05640c862b19b02899cc9cd9b92f60fa376e606dec0a68a9ab004e6f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6177737361742f6e756d6265726564537472696e674f726465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/awssat/numberedStringOrder)

Sort an array of strings based on the included numbers naturally. An alternative to PHP built-in natsort function that's actually work.

Install
-------

[](#install)

Via Composer

```
$ composer require awssat/numbered-string-order
```

Usage
-----

[](#usage)

#### Sort

[](#sort)

```
//if you are using laravel, then instead use:
//$numberedStringOrder = app(Awssat\numberedStringOrder\numberedStringOrder::class);

$numberedStringOrder = new numberedStringOrder();

$numberedStringOrder->sort([
    'episode 5',
    'episode50',
    '499',
    'episode1',
    'episode two hundred',
    'episode one',
    'episode two',
    'episode eleven',
    'episode three'
]);

>> output:
[
     "episode1",
     "episode one",
     "episode two",
     "episode three",
     "episode 5",
     "episode eleven",
     "episode50",
     "episode two hundred",
     499,
]

```

If you ask why not use the built-in function (natsort), then see the natsort output of the same example above to know why:

```
 //output of built-in function natsor(): 🤨
 [
     "499",
     "episode1",
     "episode 5",
     "episode50",
     "episode eleven",
     "episode one",
     "episode three",
     "episode two",
     "episode two hundred",
   ]
```

#### Get the numbers

[](#get-the-numbers)

If you want to use our internal numbers extracting method

```
$numberedStringOrder->getNumbers(['2digits', 'text1', 'three3', 'two cars', 'blank']);

>> output:
[
     "2digits" => 2,
     "text1" => "1",
     "three3" => "3",
     "two cars" => 2,
     "blank" => "blank",
]
```

#### Convert words to numbers

[](#convert-words-to-numbers)

This package can also be helpful if you want to convert numerical words to numbers

```
new numberedStringOrder();
$numberedStringOrder->englishWordsToNumbers('one hundred twenty-three thousand four hundred fifty-six');
>> output: 123456

//to get arabic words to number use: arabicWordsToNumbers(...)
```

Test
----

[](#test)

```
composer test
```

Currently, it supports English and Arabic.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 63% 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 ~67 days

Recently: every ~152 days

Total

10

Last Release

2586d ago

PHP version history (2 changes)1PHP ~5.6|~7.0

1.0.9PHP ~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d1839100c9cfd19f7ae04492a1c0b08c09e0956479f7a1dc4006de315c0f62e?d=identicon)[if4lcon](/maintainers/if4lcon)

![](https://avatars.githubusercontent.com/u/114794?v=4)[abdulrahman](/maintainers/abdumu)[@abdumu](https://github.com/abdumu)

---

Top Contributors

[![abdumu](https://avatars.githubusercontent.com/u/114794?v=4)](https://github.com/abdumu "abdumu (17 commits)")[![BSN4](https://avatars.githubusercontent.com/u/199647?v=4)](https://github.com/BSN4 "BSN4 (10 commits)")

---

Tags

arabicarrayepisodesnatsortnatural-sortorderorderbyphpsortsorting-algorithmsstringphparraysort

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/awssat-numbered-string-order/health.svg)

```
[![Health](https://phpackages.com/badges/awssat-numbered-string-order/health.svg)](https://phpackages.com/packages/awssat-numbered-string-order)
```

###  Alternatives

[zakirullin/mess

Convenient array-related routine &amp; better type casting

21331.4k2](/packages/zakirullin-mess)

PHPackages © 2026

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