PHPackages                             chita/topological\_sort - 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. chita/topological\_sort

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

chita/topological\_sort
=======================

Topological sort function

v3.0.1(5y ago)0112.5k↑150%MITPHPPHP &gt;=7.1.0

Since Dec 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/CHItA/TopologicalSort)[ Packagist](https://packagist.org/packages/chita/topological_sort)[ RSS](/packages/chita-topological-sort/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (9)Used By (0)

Topological sort
================

[](#topological-sort)

1.0.x: [![1.0.x](https://github.com/CHItA/TopologicalSort/workflows/Tests/badge.svg?branch=1.0.x)](https://github.com/CHItA/TopologicalSort/workflows/Tests/badge.svg?branch=1.0.x)2.0.x: [![2.0.x](https://github.com/CHItA/TopologicalSort/workflows/Tests/badge.svg?branch=2.0.x)](https://github.com/CHItA/TopologicalSort/workflows/Tests/badge.svg?branch=2.0.x)3.0.x [![master](https://github.com/CHItA/TopologicalSort/workflows/Tests/badge.svg?branch=master)](https://github.com/CHItA/TopologicalSort/workflows/Tests/badge.svg?branch=master)Topological sort is a PHP library that provides topological sort functionality.

The library uses semantic versioning and has two major versions with the only difference being whether the functions get autoloaded. As PHP does not support autoloading functions, if you choose the 1.x line, the library's files will be loaded in your autoloader (and all your files using the autoloader). To avoid that you can choose the 2.x line. If you are using OOP for everything anyway the 3.0.x line gives you the same functionality wrapped in a trait.

Compatibility guarantees
------------------------

[](#compatibility-guarantees)

One important note is that the library does not guarantee the same ordering for the same input between **any** versions. As long as the algorithm produces a correct output, we won't consider changes in the produced order a bug. The only guarantee provided is that the output will always be a valid ordering of the graph's vertices.

To illustrate this point, consider the following graph:

[![unordered DAG](docs/Graph.png)](docs/Graph.png)

One possible output of a topological sort could be the following:

[![ordered DAG](docs/Sorted.png)](docs/Sorted.png)

Notice, that `B, A, C, E, D` and `B, A, C, D, E` are also valid orderings of the graph's vertices, and hence it is possible that two consecutive minor versions would produce different ones.

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

[](#installation)

Version 1.x:

```
composer require "chita/topological_sort:1.*"

```

Version 2.x:

```
composer require "chita/topological_sort:2.*"

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Recently: every ~248 days

Total

8

Last Release

970d ago

Major Versions

v1.0.3 → v2.0.12021-01-03

v2.0.1 → v3.0.12021-01-04

1.0.x-dev → 2.0.x-dev2023-09-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/29b2c36cd2fd4bafad5717061ce4ba90075acdae6329dfd1026bcfd03fd658c2?d=identicon)[CHItA](/maintainers/CHItA)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chita-topological-sort/health.svg)

```
[![Health](https://phpackages.com/badges/chita-topological-sort/health.svg)](https://phpackages.com/packages/chita-topological-sort)
```

PHPackages © 2026

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