fev / sorter
Simple library for sorting arrays.
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-06-25 03:46:59 UTC
README
This library provide two methods (ascending, descending) for sorting arrays.
Installation
For install this library just execute the following command
$ composer require fev/sorter
Usage
For usage this library you need:
- Create object form basic class
Sorter
$sorter = new Sorter();
- Define 1 form 2 default sorting methods
SortingABC
,SortingCBA
by methodsetSortingMethod
$sorter->setSortingMethod(new SortingABC());
or
$sorter->setSortingMethod(new SortingCBA());
2.1 If you not define sorting methods, then class will be work by default mode like null object pattern.
- Use
sort
method for sorting your array.
$sorter->sort($test_arr);
Extension
For extended this library with own sorting rules create new sorting class which
implement SorterInterface
with method sort()
Tests
You can run tests with next command
$ php test.php
.
License
This project is released under the terms of the BSD-3-Clause license.
Copyright (c) 2020, FEV