PHP code example of antikirra / array-sort

1. Go to this page and download the library: Download antikirra/array-sort 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/ */

    

antikirra / array-sort example snippets


Sorter::byKey()->sort($array); // {"a":8,"b":3,"c":5,"d":11}
Sorter::byValue()->sort($array); // {"b":3,"c":5,"a":8,"d":11}

Sorter::byFunction(function ($a, $b) {
    return Sorter::desc($a['age'], $b['age']);
})->sort($users);



use Antikirra\ArraySort\Sorter;

1, 'c' => 5];

Sorter::byKey()->sort($array); // {"a":8,"b":3,"c":5,"d":11}

Sorter::byValue()->desc()->sort($array); // {"d":11,"a":8,"c":5,"b":3}

Sorter::byValue()->resetKeys()->desc()->sort($array); // [11,8,5,3]

$copy = Sorter::byValue()->desc()->sortCopy($array);