PHPackages                             mhzarei/twig-sort-by-field - 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. [Templating &amp; Views](/categories/templating)
4. /
5. mhzarei/twig-sort-by-field

ActiveLibrary[Templating &amp; Views](/categories/templating)

mhzarei/twig-sort-by-field
==========================

A Twig Extension filter to sort an array of entries (objects or arrays) by the specified field

v0.1.6(6mo ago)019Apache-2.0PHP

Since Jan 27Pushed 6mo agoCompare

[ Source](https://github.com/MHZarei/twig-sort-by-field)[ Packagist](https://packagist.org/packages/mhzarei/twig-sort-by-field)[ RSS](/packages/mhzarei-twig-sort-by-field/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Twig SortByField Extension [![](https://camo.githubusercontent.com/7aac3bd54243bc766b2afd2d1e8bf8ee47e60c79696435deecfd89d36951d115/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f766963746f726861676771766973742f547769672d736f72742d62792d6669656c642e7376673f7374796c653d666c6174)](https://travis-ci.org/victorhaggqvist/Twig-sort-by-field)
==============================================================================================================================================================================================================================================================================================================================================================

[](#twig-sortbyfield-extension-)

A Twig Extension filter to sort an array of entries (objects or arrays) by an entry field.

Since version 0.1.5 Doctrine collections can be sorted as is with no need to manually extract the array first.

Install
-------

[](#install)

With composer

```
composer require mhzarei/twig-sort-by-field

```

Usage
-----

[](#usage)

The list could look like this, but obviously with more than one key per array.

```
$base = array(
  array(
    "name" => "Redmine"
  ),
  array(
    "name" => "GitLab"
  ),
  array(
    "name" => "Jenkins"
  ),
  array(
    "name" => "Piwik"
  )
);
```

```
{% for item in base | sortbyfield('name') %}

    {{ item.name }}

{% endfor %}
```

For Symfony usage you'll want to add it as a service and tag it for Twig.

```
# app/config/services.yml
services:
    twig.extension.sortbyfield:
        class: Snilius\Twig\SortByFieldExtension
        tags:
            - { name: twig.extension }
```

License
-------

[](#license)

```
Copyright 2015 Victor Häggqvist

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance69

Regular maintenance activity

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.3% 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 ~3674 days

Total

2

Last Release

182d ago

### Community

Maintainers

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

---

Top Contributors

[![victorhaggqvist](https://avatars.githubusercontent.com/u/1887628?v=4)](https://github.com/victorhaggqvist "victorhaggqvist (21 commits)")[![AMoQu](https://avatars.githubusercontent.com/u/822917?v=4)](https://github.com/AMoQu "AMoQu (1 commits)")[![MHZarei](https://avatars.githubusercontent.com/u/3741390?v=4)](https://github.com/MHZarei "MHZarei (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mhzarei-twig-sort-by-field/health.svg)

```
[![Health](https://phpackages.com/badges/mhzarei-twig-sort-by-field/health.svg)](https://phpackages.com/packages/mhzarei-twig-sort-by-field)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3841.2M](/packages/limenius-react-bundle)[pdewit/nova-external-url

An external URL Laravel Nova field.

30383.2k](/packages/pdewit-nova-external-url)[wbrowar/guide

A CMS Guide for Craft CMS.

6154.7k1](/packages/wbrowar-guide)[localgovdrupal/localgov_base

The base theme for LocalGov Drupal websites.

13126.9k5](/packages/localgovdrupal-localgov-base)

PHPackages © 2026

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