PHPackages                             carloswph/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. carloswph/sorter

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

carloswph/sorter
================

Collection of sorting algorithms with annotations on procedures, history and functioning details.

v1.1.3(4y ago)34GPL-2.0-onlyPHP

Since Apr 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/carloswph/sorter)[ Packagist](https://packagist.org/packages/carloswph/sorter)[ RSS](/packages/carloswph-sorter/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

Sorter
======

[](#sorter)

Collection of sorting algorithms implemented in PHP classes. Also, a benchmarking class for doing performance tests using any array and passing it through all available sorting algorithms. At this moment, this library can sort arrays in the following sorting algorithms:

- PHP sort()
- Quick Sorting
- Bubble Sorting
- Heap Sorting
- Gnome Sorting
- Shell Sorting
- Comb Sorting
- Insertion Sorting
- Merge Sorting
- Selection Sorting
- Matos-Goulart Simple Sorting (recently created by myself)

Matos-Goulart Simple Sorting Algorithm © 2021 by Carlos Artur C. S. Matos is licensed under Attribution 4.0 International .

All sorting algorithms can be applied to any array of integers using the respective static method. Also, using the class Benchmark() the developer can perform all sorting methods at once, and get a var\_dump() of the benchmark times in seconds. Also, we compare all sort methods in the becnhmark with PHP's native sort() function, as reference.

Usage
=====

[](#usage)

```
require __DIR__ . '/vendor/autoload.php';

$matos = \Sorter\MatosGoulart::sort([2, 6, 78, 11, 23, 1, 4, 1902, 192]);

/*
Results in:

array(9) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(4)
  [3]=>
  int(6)
  [4]=>
  int(11)
  [5]=>
  int(23)
  [6]=>
  int(78)
  [7]=>
  int(192)
  [8]=>
  int(1902)
}

*/
```

Obviously, all other sorting methods will result in the same response array - as the main objective of this library is to realize benchmarking tests amongst all possible algorithms, rather than sorting numbers itself. All details on the algorithms and some pseudocode for implementations in other programming languages can be found on each class' docblock comments.

Benchmark
---------

[](#benchmark)

Also, this library has a Benchmark class, which can be used to subject an array to all sorting methods, and then return benchmark times for each of the sorting algorithms. As simple as follows:

```
use Sorter\Benchmark;

require __DIR__ . '/vendor/autoload.php';

$ro = new Benchmark([2, 4, 1, 23, 32, 11, 45, 67, 5, 233455, 344 , 7, 24, 67, 1111111, 111, 34, 2344]);
$ro->get();

/*
RESULTS IN:

array(8) {
  ["quick"]=>
  string(14) "0.127814000000"
  ["bubble"]=>
  string(14) "0.033583000000"
  ["heap"]=>
  string(14) "0.035445000000"
  ["gnome"]=>
  string(14) "0.015428000000"
  ["shell"]=>
  string(14) "0.012064000000"
  ["comb"]=>
  string(14) "0.000609000000"
  ["insertion"]=>
  string(14) "0.015089000000"
  ["matos_goulart"]=>
  string(14) "0.011882000000"
}
*/
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Every ~8 days

Total

5

Last Release

1823d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/13c91dcf5209989038da335ba42538fa84670bf27400f220d182a76e0a720b74?d=identicon)[carloswph](/maintainers/carloswph)

---

Top Contributors

[![meuppt](https://avatars.githubusercontent.com/u/37983141?v=4)](https://github.com/meuppt "meuppt (9 commits)")

---

Tags

benchmarkingAlgorithmsortingalgorithmsbubble sortquick sortheap sort

### Embed Badge

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

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

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[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)[donatello-za/rake-php-plus

Yet another PHP implementation of the Rapid Automatic Keyword Extraction algorithm (RAKE).

271865.1k10](/packages/donatello-za-rake-php-plus)[icecave/parity

A customizable deep comparison library.

516.8M10](/packages/icecave-parity)[doganoo/php-algorithms

A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell

9485.4k7](/packages/doganoo-php-algorithms)

PHPackages © 2026

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