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

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

list-sorter/list-sorter
=======================

Lists Sorting Handler in Laravel

v1.0.9(8y ago)27271MITPHPPHP &gt;=7CI failing

Since Sep 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/iranianpep/list-sorter)[ Packagist](https://packagist.org/packages/list-sorter/list-sorter)[ Docs](https://github.com/iranianpep/list-sorter)[ RSS](/packages/list-sorter-list-sorter/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (21)Used By (0)

List Sorter
===========

[](#list-sorter)

List Sorting Handler in Laravel

[![Latest Stable Version](https://camo.githubusercontent.com/5fe83ca1f5bb298d5b547bf7561445fdbc46e6ca78093114a1fd0a94f1f1f266/68747470733a2f2f706f7365722e707567782e6f72672f6c6973742d736f727465722f6c6973742d736f727465722f762f737461626c65)](https://packagist.org/packages/list-sorter/list-sorter)[![Build Status](https://camo.githubusercontent.com/5c89180f211e46008ddbb11fff7715329d8a03b171f8911ac4b9e5b730261f22/68747470733a2f2f7472617669732d63692e6f72672f6972616e69616e7065702f6c6973742d736f727465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/iranianpep/list-sorter)[![Build Status](https://camo.githubusercontent.com/d299bb664c220793a15f99daa0fa593e5c5007074a6218895ec14cb8345d354c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6972616e69616e7065702f6c6973742d736f727465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iranianpep/list-sorter/build-status/master)[![Code Climate](https://camo.githubusercontent.com/c300bbbde559707dabf1dcf7296232d187739d5575f9ce4920468f4610341c77/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6972616e69616e7065702f6c6973742d736f727465722f6261646765732f6770612e737667)](https://codeclimate.com/github/iranianpep/list-sorter)[![Test Coverage](https://camo.githubusercontent.com/807ff4921fdb6b35b16991af17cd7837893a53eaabbfbdbbc781d09b016ba70a/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6972616e69616e7065702f6c6973742d736f727465722f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/iranianpep/list-sorter/coverage)[![Code Coverage](https://camo.githubusercontent.com/ea30994226e4007705155532e7123c79cca87f00e887a1f0c4fd5ab46f125d5d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6972616e69616e7065702f6c6973742d736f727465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iranianpep/list-sorter/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bc5c538e3850f5b6a989bf31d3d4fb78fdbdd7016fdbdf3c2627c84f4bd73c9c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6972616e69616e7065702f6c6973742d736f727465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iranianpep/list-sorter/?branch=master)[![Issue Count](https://camo.githubusercontent.com/2490527cc8beefceaa60e78b3a04470d6a2df36eb0c233c123101a3e1e5cf1ce/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6972616e69616e7065702f6c6973742d736f727465722f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/iranianpep/list-sorter)[![License](https://camo.githubusercontent.com/e2a24dc2d564a451cb2d3a7aec758e8e8dfa405734f3e77edc2f3c85f3dd77d0/68747470733a2f2f706f7365722e707567782e6f72672f6c6973742d736f727465722f6c6973742d736f727465722f6c6963656e7365)](https://packagist.org/packages/list-sorter/list-sorter)[![StyleCI](https://camo.githubusercontent.com/ab736cd811cdcd45204948908527cd7654ff165318bd8c98fcdfa97d5f827ea7/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130353135383938322f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/105158982)[![Codacy Badge](https://camo.githubusercontent.com/059869e782bdc8575340d02294af28fa06c48986f1d820395a17d99addad167b/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6636373938636533633030653464653038336438396632383962366339323835)](https://www.codacy.com/app/iranianpep/list-sorter?utm_source=github.com&utm_medium=referral&utm_content=iranianpep/list-sorter&utm_campaign=Badge_Grade)[![Packagist](https://camo.githubusercontent.com/86af18e80a8cd9684387f1c1dc6920ffea6782264fcc71684ca16286fe982783/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6973742d736f727465722f6c6973742d736f727465722e737667)](https://packagist.org/packages/list-sorter/list-sorter)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/iranianpep/list-sorter/master/LICENSE)

Usage
-----

[](#usage)

Add the sorter to your composer:

```
composer require list-sorter/list-sorter

```

In the controller:

```
$listSorter = new ListSorter($request, [
    new SortableItem('name'),
    new SortableItem('created_at'),
]);

$listSorter->setDefaultSortBy('created_at');
$listSorter->setDefaultSortDir('desc');

// sort by e.g. name or created_at
$sortBy = $listSorter->getSortBy();

// sort direction e.g. asc or desc
$sortDir = $listSorter->getSortDir();

$items = User::orderBy($sortBy, $sortDir)->paginate(10);

return view('index', [
    'items' => $items,
    'listSorter' => $listSorter,
]);

```

Or the shorter version (column and title are determined based on the key):

```
$listSorter = new ListSorter(
    $request,
    [
        'title',
        'created_at',
    ]
);

$listSorter->setDefaultSortBy('created_at');
$listSorter->setDefaultSortDir('desc');

```

In the view and the table header:

```

        @foreach($listSorter->getSortableItems() as $sortableItem)
            @if ($sortableItem->isHidden === true)
                @continue
            @endif

                    {{ $sortableItem->getTitle() }}
                    @if ($sortableItem->isSelected() === true)
                        @if (in_array($sortableItem->getSortDir(), ['asc', 'desc']))

                        @else

                        @endif
                    @else

                    @endif

        @endforeach

```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 98.8% 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 ~14 days

Recently: every ~31 days

Total

10

Last Release

3063d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4e337f9891a92e469bd236f9774b8c6a894b05a31fc4f3d2da1f4010977b44e?d=identicon)[ehsan.abb](/maintainers/ehsan.abb)

---

Top Contributors

[![iranianpep](https://avatars.githubusercontent.com/u/3667439?v=4)](https://github.com/iranianpep "iranianpep (80 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

laravellistordersorting

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[happy-types/enumerable-type

Strongly typed implementation of enumerable type in PHP which helps us to write a safer more readable code.

4542.9k](/packages/happy-types-enumerable-type)[codeconsortium/ccdn-forum-bundle

CCDN Forum Bundle

5915.4k1](/packages/codeconsortium-ccdn-forum-bundle)

PHPackages © 2026

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