Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Sort an array by values using a user-defined comparison function
<?php usort(array &$array, callable $callback): true
<?php         if ($this->sort_by_score) {

            usort($clone, function ($a, $b) {

                if ($a['score'] > $b['score']) {

                    return -1;

                } elseif ($a['score'] < $b['score']) {

                    return 1;

                } else {

                    return 0;

                }

            });

        }
<?php         $arr = $this->all();



        usort($arr, function ($a, $b) use ($sorts) {

            foreach ($sorts as $sort) {

                $bits = explode(':', $sort);

                $sort_by = $bits[0];

                $sort_dir = array_get($bits, 1);



                [$one, $two] = $this->getSortableValues($sort_by, $a, $b);



                $result = Compare::values($one, $two);



                if ($result !== 0) {

                    return ($sort_dir === 'desc') ? $result * -1 : $result;

                }

            }



            return 0;

        });



        return new static($arr);

    }