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

v2.0.1 2020-08-24 16:34 UTC

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:

  1. Create object form basic class Sorter
$sorter = new Sorter();
  1. Define 1 form 2 default sorting methods SortingABC, SortingCBA by method setSortingMethod
$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.
  1. 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

license

This project is released under the terms of the BSD-3-Clause license.

Copyright (c) 2020, FEV