PHPackages                             pustato/topsort - 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. pustato/topsort

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

pustato/topsort
===============

Topological sorting implementation in PHP

v1.0.1(8y ago)145MITPHPPHP &gt;=7.0

Since Mar 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/pustato/topsort)[ Packagist](https://packagist.org/packages/pustato/topsort)[ RSS](/packages/pustato-topsort/feed)WikiDiscussions master Synced 2mo ago

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

Topological Sort in PHP
=======================

[](#topological-sort-in-php)

Simple [Topological Sorting](https://en.wikipedia.org/wiki/Topological_sorting "Wikipedia Link") (aka Dependency Resolution) algorithm implementation in PHP.

Install
-------

[](#install)

```
composer require pustato/topsort

```

Example usage
-------------

[](#example-usage)

Implement interface `\Pustato\TopSort\Contracts\Sortable`:

```
// in SiteAsset.php
class SiteAsset implements Pustato\TopSort\Contracts\Sortable
{

    public function getId()
    {
        return static::class;
    }

    public function getDependencies()
    {
        return [
            JQueryAsset::class, BootstrapAsset::class
        ];
    }

    ...
    // Asset implementation
}
```

```
// in BootstrapAsset.php
class BootstrapAsset implements Pustato\TopSort\Contracts\Sortable
{

    public function getId()
    {
        return static::class;
    }

    public function getDependencies()
    {
        return [
            JQueryAsset::class
        ];
    }

    ...
    // Asset implementation
}
```

```
// in JQueryAsset.php
class JQueryAsset implements Pustato\TopSort\Contracts\Sortable
{

    public function getId()
    {
        return static::class;
    }

    public function getDependencies()
    {
        return [];
    }

    ...
    // Asset implementation
}
```

Add all sortable classes to `\Pustato\TopSort\Collection` and sort them:

```
$assetsCollection = new \Pustato\TopSort\Collection([
    new SiteAsset(), new JQueryAsset(), new BootstrapAsset()
]);
$result = $assetsCollection->getSorted();
var_dump($result);
```

And you will get:

```
array(3) {
  [0] => class JQueryAsset#1 (0) {}
  [1] => class BootstrapAsset#2 (0) {}
  [2] => class SiteAsset#3 (0) {}
}

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3170d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

php7topological-sort

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pustato-topsort/health.svg)

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

###  Alternatives

[wapmorgan/morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.

8351.3M7](/packages/wapmorgan-morphos)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.4k423.9k30](/packages/mcp-sdk)[hackzilla/password-generator

Password Generator Library

3035.2M15](/packages/hackzilla-password-generator)[alibaba/nacos

阿里巴巴nacos配置中心php客户端

19340.8k1](/packages/alibaba-nacos)[bvdputte/kirby-fingerprint

Cache-busting utility to fingerprint assets (JS/CSS) in Kirby 3

1610.0k](/packages/bvdputte-kirby-fingerprint)

PHPackages © 2026

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