1. Go to this page and download the library: Download dragon-code/size-sorter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use DragonCode\SizeSorter\SizeSorter;
// Laravel models collection
$items = Size::get();
return new SizeSorter($items)
->column('title')
->sort();
use DragonCode\SizeSorter\SizeSorter;
return SizeSorter::items([
// ...
])->sort();
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();
use DragonCode\SizeSorter\Enum\Group;
use DragonCode\SizeSorter\SizeSorter;
return new SizeSorter($items)
->orderBy([
Group::BraSize,
Group::OtherSizes,
])
->sort();
use DragonCode\SizeSorter\SizeSorter;
return new SizeSorter($items)
->column('foo')
->sort();
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();