PHPackages                             vpinti/sorted-linked-list - 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. vpinti/sorted-linked-list

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

vpinti/sorted-linked-list
=========================

A blazing fast, type-safe sorted linked list library for PHP. Supports automatic sorting, integer and string values, and modern PHP features.

00PHP

Since Aug 21Pushed 8mo agoCompare

[ Source](https://github.com/vpinti/sortedLinkedList)[ Packagist](https://packagist.org/packages/vpinti/sorted-linked-list)[ RSS](/packages/vpinti-sorted-linked-list/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Sorted Linked List
==================

[](#sorted-linked-list)

A blazing fast, type-safe, and fully tested sorted linked list library for PHP. Supports both integer and string values, with automatic sorting in ascending or descending order. Designed for performance, maintainability, and extensibility.

Features
--------

[](#features)

- Automatic sorting (ascending/descending)
- Type safety: only one type per list (int or string)
- Fast insert, delete, contains, clear, and iteration Internal sorting logic (no external comparator needed)
- Simple, modern API

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

[](#installation)

Install via Composer:

```
composer require vpinti/sorted-linked-list
```

Usage
-----

[](#usage)

```
use Vpinti\SortedLinkedList\SortedLinkedList;
use Vpinti\SortedLinkedList\Enum\SortOrder;

$list = new SortedLinkedList(SortOrder::ASC);
$list->insert(5);
$list->insert(2);
$list->insert(8);
$list->insert(1);

// Get sorted values as array
$values = $list->toArray(); // [1, 2, 5, 8]

// Check if a value exists
$list->contains(5); // true

// Remove a value
$list->delete(2);

// Iterate
foreach ($list as $value) {
    echo $value . PHP_EOL;
}

// Clear the list
$list->clear();

// Use with strings
$stringList = new SortedLinkedList(SortOrder::DESC);
$stringList->insert('banana');
$stringList->insert('apple');
$stringList->insert('pear');
// $stringList->toArray(); // ['pear', 'banana', 'apple']
```

API
---

[](#api)

### SortedLinkedList

[](#sortedlinkedlist)

- `__construct(SortOrder $order = SortOrder::ASC)`
- `insert(int|string $value): void`
- `delete(int|string $value): bool`
- `contains(int|string $value): bool`
- `clear(): void`
- `toArray(): array`
- `count(): int`
- `__toString(): string`
- Iterator support (`foreach`)

### Extensibility

[](#extensibility)

Sorting logic is handled internally by the `SortedLinkedList` class. Custom comparators are not required or supported in this version.

Contributing
------------

[](#contributing)

Pull requests and stars are welcome! For major changes, please open an issue first to discuss what you would like to change.

License
-------

[](#license)

MIT

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance42

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ddc4dbe6f2af39bda2b1372a46ff713c6d12194e376860aeb664a3273c3e28e6?d=identicon)[vpinti](/maintainers/vpinti)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/vpinti-sorted-linked-list/health.svg)

```
[![Health](https://phpackages.com/badges/vpinti-sorted-linked-list/health.svg)](https://phpackages.com/packages/vpinti-sorted-linked-list)
```

###  Alternatives

[baidu/aip-sdk

baidu pulic ai php sdk

119104.9k6](/packages/baidu-aip-sdk)[thestringler-laravel/manipulator

A Laravel package for The Stringler

315.0k](/packages/thestringler-laravel-manipulator)

PHPackages © 2026

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