PHP code example of chmiello / array-sort

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

    

chmiello / array-sort example snippets




use Chmiello\ArraySortPackage\ArraySort;

$noSortedData = [
    ['name' => 'Giacomo', 'surname' => 'Agostini', 'time' => 11.25],
    ['name' => 'Francesco', 'surname' => 'Bagnaia', 'time' => 11.23],
    ['name' => 'Marco', 'surname' => 'Bezzecchi', 'time' => 12.01],
    ['name' => 'Max', 'surname' => 'Biaggi', 'time' => 11.25],
    ['name' => 'Anthony', 'surname' => 'Groppi', 'time' => 11.48],
    ['name' => 'Valentino', 'surname' => 'Rossi', 'time' => 11.21],
    ['name' => 'Marco', 'surname' => 'Melandri', 'time' => 11.21],
    ['name' => 'Alessandro', 'surname' => 'Tonucci', 'time' => 11.25]
    ];

    $sortedArray = (new ArraySort($noSortedData))->asc('time')->desc('surname')->sort()->getItems();
    
    dump($sortedArray);