PHPackages                             dragon-code/size-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. dragon-code/size-sorter

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

dragon-code/size-sorter
=======================

Easily sort clothing size, height, bra size, furniture size and more

2.1.0(2mo ago)3915.4k↓33.3%2MITPHPPHP ^8.2CI passing

Since Feb 2Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/TheDragonCode/size-sorter)[ Packagist](https://packagist.org/packages/dragon-code/size-sorter)[ Fund](https://boosty.to/dragon-code)[ Fund](https://yoomoney.ru/to/410012608840929)[ RSS](/packages/dragon-code-size-sorter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (16)Used By (0)

Size Sorter
===========

[](#size-sorter)

  ![Size Sorter](https://camo.githubusercontent.com/d390bf87d675d311bd6ba6c5b591def342c73f0f44dc055a6af0bb864009dee0/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f53697a65253230536f727465722e706e673f7061747465726e3d746f706f677261706879267374796c653d7374796c655f3226666f6e7453697a653d3130307078266d643d312673686f7757617465726d61726b3d31267468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d647261676f6e2d636f646525324673697a652d736f72746572266465736372697074696f6e3d456173696c792b736f72742b636c6f7468696e672b73697a652532432b6865696768742532432b6272612b73697a652532432b6675726e69747572652b73697a652b616e642b6d6f726526696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)[![Stable Version](https://camo.githubusercontent.com/204083a8a12a4a7b73e237ad0e01d839a7a02164773c6dabed73fafafcdd3230/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f546865447261676f6e436f64652f73697a652d736f727465723f6c6162656c3d737461626c65267374796c653d666c61742d737175617265)](https://packagist.org/packages/dragon-code/size-sorter)[![Total Downloads](https://camo.githubusercontent.com/442e83fdbcc751a771594430e42d2986633250cbad42a6b25d5eaf065c6f5cdb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f647261676f6e2d636f64652f73697a652d736f727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dragon-code/size-sorter)[![Github Workflow Status](https://camo.githubusercontent.com/3c9e26e487ec9076f8f3381457227b0444e30d71ad40e32b9545f8eff2da81c1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f546865447261676f6e436f64652f73697a652d736f727465722f74657374732e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/TheDragonCode/size-sorter/actions)[![License](https://camo.githubusercontent.com/ec63346863cb92711e8f8e24a5000b286e12db4c4c5b87fd38f06ad4143f3b31/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f647261676f6e2d636f64652f73697a652d736f727465722e7376673f7374796c653d666c61742d737175617265)](LICENSE)

> Easily sort clothing size, height, bra size, furniture size and more

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

[](#installation)

To get the latest version of `Size Sorter`, simply require the project using [Composer](https://getcomposer.org):

```
composer require dragon-code/size-sorter
```

Or manually update `require` block of `composer.json` and run composer update.

```
{
    "require": {
        "dragon-code/size-sorter": "^2.0"
    }
}
```

Tip

When using the Laravel framework, make sure that its version is 11.0 or greater.

Usage
-----

[](#usage)

When calling a sort with common values, each element will be assigned to one of five groups:

1. Letter clothing size (XXS, XS, M, L, 2XL, etc.)
2. Numerical size of clothes and shoes (9, 10, 44-46, 48, etc.)
3. Bra size (70B, 75A, 80C, etc...)
4. Overall dimensions of items (40x38x19 sm, etc.)
5. Volumes (450 ml, 30 l, 450ml, 30l, etc.)
6. Other values

```
use DragonCode\SizeSorter\SizeSorter;

return new SizeSorter([
    'XXL',
    '26',
    '28',
    'XL',
    'ONE SIZE',
    'XXS',
    '2',
    '54',
])->sort();

/*
 * Returns:
 *
 * Illuminate\Support\Collection([
 *   'XXS',
 *   'XL',
 *   'XXL',
 *   '2',
 *   '26',
 *   '28',
 *   '54',
 *   'ONE SIZE',
 * ])
 */
```

```
use DragonCode\SizeSorter\SizeSorter;

// Laravel models collection
$items = Size::get();

return new SizeSorter($items)
    ->column('title')
    ->sort();
```

The static `items` method is also available:

```
use DragonCode\SizeSorter\SizeSorter;

return SizeSorter::items([
    // ...
])->sort();
```

### Groups Order

[](#groups-order)

By default, sizes are sorted by the following logical blocks:

1. Letter clothing size (XXS, XS, M, L, 2XL, etc.)
2. Numerical size of clothes and shoes (9, 10, 44-46, 48, etc.)
3. Bra size (70B, 75A, 80C, etc...)
4. Overall dimensions of items (40x38x19 sm, etc.)
5. Volumes (450 ml, 30 l, 450ml, 30l, etc.)
6. Other values

But you can change the order by specifying identifiers as the third parameter:

```
use DragonCode\SizeSorter\Enum\Group;
use DragonCode\SizeSorter\SizeSorter;

return new SizeSorter($items)
    ->orderBy([
        Group::BraSize,
        Group::OtherSizes,
        Group::OverallDimensions,
        Group::ClothesAndShoes,
        Group::VolumeGroup,
        Group::LetterClothingSize,
    ])
    ->sort();
```

The final array will be formed in the specified order:

```
3 - 5 - 4 - 2 - 1

```

You can also specify some groups. For example:

```
use DragonCode\SizeSorter\Enum\Group;
use DragonCode\SizeSorter\SizeSorter;

return new SizeSorter($items)
    ->orderBy([
        Group::BraSize,
        Group::OtherSizes,
    ])
    ->sort();
```

In this case, the first two logical groups will be sorted in the specified order, and the subsequent ones will be in ascending order:

```
3 - 5 - 1 - 2 - 4

```

### Custom Column

[](#custom-column)

When working with an array of objects, you can specify which value can be used for sorting.

```
use DragonCode\SizeSorter\SizeSorter;

return new SizeSorter($items)
    ->column('foo')
    ->sort();
```

You can also use "dotted" notation:

```
use DragonCode\SizeSorter\SizeSorter;

$items = [
    [
        'foo' => [
            'bar' => [
                'baz' => 'Some value',
            ]
        ]
    ]
];

return new SizeSorter($items)
    ->column('foo.bar.baz')
    ->sort();
```

And you can use the callback function in the same way:

```
use DragonCode\SizeSorter\SizeSorter;

class Foo
{
    public function __construct(
        public int $number,
        public string $value1,
        public string $value2,
    ) {}
}

$items = [
    new Foo(1, 'first 1', 'first 2'),
    new Foo(2, 'second 1', 'second 2'),
];

return new SizeSorter($items)
    ->column(function (Foo $item) {
        return $item->number % 2 === 0
            ? $item->value1
            : $item->value2;
    })
    ->sort();
```

And this is also possible:

```
use DragonCode\SizeSorter\SizeSorter;

$items = [
    ['foo' => 'XS'],
    ['foo' => '2XS'],
    ['foo' => '3XL'],
];

return new SizeSorter($items)
    ->column(function (array $item) {
        return match ($item['foo']) {
            '2XS' => 'XXS',
            '3XL' => 'XXXL',
            default => $item['foo']
        };
    })
    ->sort();
```

Upgrade Guide
-------------

[](#upgrade-guide)

You can find the upgrade documentation [here](UPGRADE.md).

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE).

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance82

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 82.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 ~88 days

Recently: every ~59 days

Total

14

Last Release

60d ago

Major Versions

1.x-dev → 2.0.02025-07-28

PHP version history (2 changes)v1.0.0PHP ^8.1

2.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![andrey-helldar](https://avatars.githubusercontent.com/u/10347617?v=4)](https://github.com/andrey-helldar "andrey-helldar (135 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")

---

Tags

sorterdragon codeandrey helldarsizesize-sorterbra-sizefurniture-sizeclothes

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/dragon-code-size-sorter/health.svg)

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

###  Alternatives

[illuminate/support

The Illuminate Support package.

583107.1M34.5k](/packages/illuminate-support)[dragon-code/pretty-array

Simple conversion of an array to a pretty view

177.6M4](/packages/dragon-code-pretty-array)[gabrielelana/byte-units

Library to parse, format and convert byte units

1672.2M19](/packages/gabrielelana-byte-units)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[sarfraznawaz2005/composer-cost

Displays cost/size of each composer package installed.

368.0k](/packages/sarfraznawaz2005-composer-cost)

PHPackages © 2026

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