antindehoda / sort-library
Sorting library
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/antindehoda/sort-library
Requires
- php: >=7.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.13
This package is auto-updated.
Last update: 2025-12-06 11:58:13 UTC
README
Library sorting arrays of numbers and arrays of strings.
Contains two standard implementations of sorting algorithms: from large to small (DecreaseSorter) and from small to large (IncreaseSorter).
Also implemented the design pattern "Null Object" (NullObjectSorter).
Installation
To install the library, run this command:
$ composer require antindehoda/sort-library
Usage
- Create the sorting strategy you need.
$increaseStrategy = new IncreaseSorter();
- Create Sorter object
$sorter = new Sorter($increaseStrategy);
- If you need to change strategy on the fly, you can do it using the method
setStrategy.
$decreaseStrategy = new DecreaseSorter(); $sorter->setStrategy($decreaseStrategy);
- Sort the array. The method
sortof the Sorter object returns a sorted array.
$sorter->sort($array)
License
This project is released under the terms of the BSD-3-Clause license.
Copyright (c) 2019, Anton Degoda