PHPackages                             arifulhb/php-algorithms - 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. arifulhb/php-algorithms

ActiveLibrary

arifulhb/php-algorithms
=======================

Multi-dimensional Array &amp; Object Sorting in PHP

v0.1.1(4y ago)01MITPHPPHP ^7.3

Since Jun 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/arifulhb/php-algorithms)[ Packagist](https://packagist.org/packages/arifulhb/php-algorithms)[ RSS](/packages/arifulhb-php-algorithms/feed)WikiDiscussions main Synced 1w ago

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

Multi-dimensional Array &amp; Object Sorting in PHP
===================================================

[](#multi-dimensional-array--object-sorting-in-php)

Sort a multidimensional `array` or `object` by `String` or `integer` or both types.

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

[](#installation)

Install the package on your php application.

```
composer require arifulhb/php-algorithms

```

Sort by Array
-------------

[](#sort-by-array)

For example, if you have an array, and you want to sort by name or by price or both, you can use this package to sort.

```
 $items = [
    [
        'name' => 'computer',
        'price' => 4,
    ],
    [
        'name' => 'tv',
        'price' => 9,
    ],
    [
        'name' => 'apple',
        'price' => 1,
    ],
    [
        'name' => 'airpod',
        'price' => 1,
    ],
    [
        'name' => 'airtag',
        'price' => 3,
    ],
    [
        'name' => 'shampoo',
        'price' => 5,
    ]
];

```

### How to

[](#how-to)

```
// create a configuration object specifying integer and string field accordingly.
$config = new SortConfiguration('price', 'name');

// create sort object with the configuration
$sortArray = new SortArray($config);

// sort the array
$result = $sortArray->sort($products);

```

Sort by Object
--------------

[](#sort-by-object)

Same as sort by array, but here you may have an array of object to sort. For example,

```
$arrayOfObjects = [
    new Product('computer', 4),
    new Product('tv', 9),
    new Product('apple', 1),
    new Product('airpod', 1),
    new Product('airtag', 3),
    new Product('shampoo', 5)
];

```

### How to

[](#how-to-1)

```
// create a configuration object specifying integer and string field accordingly.
$config = new SortConfiguration('price', 'name');

// create sort object with the configuration
$sortObject = new SortObject($config);

// sort the array
$result = $sortObject->sort($products);

```

Development
-----------

[](#development)

To run the test cases,

```
composer run-script tests

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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 ~0 days

Total

2

Last Release

1805d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1863616?v=4)[Ariful Haque](/maintainers/arifulhb)[@arifulhb](https://github.com/arifulhb)

---

Top Contributors

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

---

Tags

algorithmsphpphp7sortingsorting-algorithms

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/arifulhb-php-algorithms/health.svg)

```
[![Health](https://phpackages.com/badges/arifulhb-php-algorithms/health.svg)](https://phpackages.com/packages/arifulhb-php-algorithms)
```

PHPackages © 2026

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