PHP code example of vanderlee / php-stable-sort-functions

1. Go to this page and download the library: Download vanderlee/php-stable-sort-functions 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/ */

    

vanderlee / php-stable-sort-functions example snippets


use StableSort\StableSort;

$items = array(
    array('name' => 'first', 'score' => 10),
    array('name' => 'second', 'score' => 5),
    array('name' => 'third', 'score' => 10),
);

StableSort::usort($items, function ($left, $right) {
    return $left['score'] - $right['score'];
});