PHPackages                             vanderlee/php-stable-sort-functions - 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. vanderlee/php-stable-sort-functions

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

vanderlee/php-stable-sort-functions
===================================

Class of stable sort methods. Equal values remain in the original order. Only different values are sorted.

2.0.6(2y ago)33768.3k↓41.8%81MITPHPPHP &gt;=5.3.0

Since Jun 10Pushed 2y ago2 watchersCompare

[ Source](https://github.com/vanderlee/PHP-stable-sort-functions)[ Packagist](https://packagist.org/packages/vanderlee/php-stable-sort-functions)[ Docs](https://github.com/vanderlee/PHP-stable-sort-functions)[ RSS](/packages/vanderlee-php-stable-sort-functions/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)DependenciesVersions (10)Used By (1)

PHP stable sort
===============

[](#php-stable-sort)

Version 2.0.6 [![Build Status](https://camo.githubusercontent.com/a743d1b51d7371e347d55eab32b9692ba4a86f51dbaa786702822fcedd2a7c88/68747470733a2f2f7472617669732d63692e6f72672f76616e6465726c65652f5048502d737461626c652d736f72742d66756e6374696f6e732e737667)](https://travis-ci.org/vanderlee/PHP-stable-sort-functions)

Copyright © 2015-2018 Martijn van der Lee (). MIT Open Source license applies.

Introduction
------------

[](#introduction)

Class of stable sort utility methods and standalone functions. Equal values remain in the original order. Only different values are sorted.

These sort utility methods follow the same interface and have the same functionality and features as the builtin sort utility methods (except they add guaranteed sort order).

Static methods
--------------

[](#static-methods)

- `bool StableSort::arsort ( array &$array [, int $sort_flags = SORT_REGULAR ] )`
- `bool StableSort::asort ( array &$array [, int $sort_flags = SORT_REGULAR ] )`
- `bool StableSort::natcasesort ( array &Sarray )`
- `bool StableSort::natsort ( array &Sarray )`
- `bool StableSort::uasort ( array &$array , callable $value_compare_func )`
- `bool StableSort::uksort ( array &$array , callable $value_compare_func )`
- `bool StableSort::usort ( array &$array , callable $value_compare_func )`

For backwards compatibility, functions (prefixed with `s`) are available that utilize the utility class.

Tests
-----

[](#tests)

PHPUnitTest testcases are included (group `stablesort`) in the `tests`directory.

Disclaimers
-----------

[](#disclaimers)

Only methods that make sense for stable sorting are included, so no `sort` or `ksort` variants. If you can demonstrate the case for any missing function, please let me know and they will be included.

These are not the fastest possible implementations. In fact, I guarantee they are not. Performance has been sacrificed for compatibility with their builtin counterparts.

Changes
-------

[](#changes)

### 2.0.6

[](#206)

- PHP 8 sorts stable by default. Use native methods if PHP 8 or more recent.

### 2.0.1

[](#201)

- Merge @joelpittet 2.0.0 into main branch, cleaning Drupal specifics.

### 2.0.0

[](#200)

- Converted to Utility class. By @joelpittet

### 1.0.3

[](#103)

- Added `reset` calls to `sasort`/`sarsort` to ensure pointer. By @emilv.

### 1.0.2

[](#102)

- PHP 5.3 compatibility changes by @folliked.

### 1.0.1

[](#101)

- composer.json added by @thebeline.

### 1.0

[](#10)

- Initial public release

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~392 days

Recently: every ~731 days

Total

9

Last Release

897d ago

Major Versions

1.0.3 → 2.0.12016-01-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/59428f021d3985e299ebd676bbe50fa592430f8dd1d57af38df8833b19079ee8?d=identicon)[vanderlee](/maintainers/vanderlee)

---

Top Contributors

[![vanderlee](https://avatars.githubusercontent.com/u/649240?v=4)](https://github.com/vanderlee "vanderlee (36 commits)")[![adhocore](https://avatars.githubusercontent.com/u/2908547?v=4)](https://github.com/adhocore "adhocore (8 commits)")[![folliked](https://avatars.githubusercontent.com/u/1079982?v=4)](https://github.com/folliked "folliked (1 commits)")[![jlherren](https://avatars.githubusercontent.com/u/1890851?v=4)](https://github.com/jlherren "jlherren (1 commits)")[![morozov](https://avatars.githubusercontent.com/u/59683?v=4)](https://github.com/morozov "morozov (1 commits)")[![thebeline](https://avatars.githubusercontent.com/u/130580?v=4)](https://github.com/thebeline "thebeline (1 commits)")

---

Tags

arraysortstableusortarsortasortnatcasesortnatsortuasortuksort

### Embed Badge

![Health badge](/badges/vanderlee-php-stable-sort-functions/health.svg)

```
[![Health](https://phpackages.com/badges/vanderlee-php-stable-sort-functions/health.svg)](https://phpackages.com/packages/vanderlee-php-stable-sort-functions)
```

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k430.2M1.4k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k317.3M3.2k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

565335.0M36](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k13.2M174](/packages/cuyz-valinor)[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31053.8M53](/packages/openlss-lib-array2xml)

PHPackages © 2026

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