1. Go to this page and download the library: Download dimaskao/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/ */
dimaskao / sorter example snippets
use Dimaskao\Sorter\Sorter //r; //|\
use Dimaskao\Sorter\SortASC; //|- Choose what you need
use Dimaskao\Sorter\SortDESC; //|/
$sorter = new Sorter(new SortASC());
$sorter->sort($array);
$sorter = new Sorter(new SortDESC());
$sorter->setSorter(new SortASC());
$sorter->setSorter(new SortASC());//this will sort array
$sorter->setSorter(new NullSorter());//this would not sort array
$b = $sorter->sort($arr);
use Dimaskao\Sorter\SorterInterface;
class YourFormat implements SorterInterface {
}
use Dimaskao\Sorter\NullSorter;
use Dimaskao\Sorter\SortASC;
use Dimaskao\Sorter\SortDESC;
use Dimaskao\Sorter\Sorter;
$arr = [9, 0, 1, 5, 77, -5];
$sorter = new Sorter(new SortDESC());
$a = $sorter->sort($arr);
\print_r($a);
$sorter->setSorter(new SortASC());
$b = $sorter->sort($arr);
\print_r($b);
$sorter->setSorter(new SortASC());
$sorter->setSorter(new NullSorter());
$b = $sorter->sort($arr);
\print_r($b);