Bravo3\Orm\Drivers\Filesystem\Workers\AddSortedIndexWorker::sortAndWrite PHP Method

sortAndWrite() protected method

Sort the data and write it to the filesystem
protected sortAndWrite ( array $content, string $key )
$content array
$key string
    protected function sortAndWrite(array $content, $key)
    {
        usort($content, function (array $a, array $b) {
            list($a_score, ) = $a;
            list($b_score, ) = $b;
            if ($a_score == $b_score) {
                return 0;
            } else {
                return $a_score < $b_score ? -1 : 1;
            }
        });
        $this->io_driver->write($key, json_encode($content));
    }