public function uksort(callable $callback): Collection
    {
        $items = $this->items;
        $keys = array_combine(array_keys($items), range(1, count($items)));

        uksort($items, function ($a, $b) use ($callback, $keys) {
            $result = call_user_func($callback, $a, $b);

            return $result === 0 ? $keys[$a] - $keys[$b] : $result;
        });

        return new static($items);
    }
public function uksort(callable $callback): Collection
    {
        $items = $this->items;
        $keys = array_combine(array_keys($items), range(1, count($items)));

        uksort($items, function ($a, $b) use ($callback, $keys) {
            $result = call_user_func($callback, $a, $b);

            return $result === 0 ? $keys[$a] - $keys[$b] : $result;
        });

        return new static($items);
    }
public function uksort ( callable $ callback ) : Collection { $ items = $ this -> items ; $ keys = array_combine ( array_keys ( $ items ) , range ( 1 , count ( $ items ) ) ) ; uksort ( $ items , function ( $ a , $ b ) use ( $ callback , $ keys ) { $ result = call_user_func ( $ callback , $ a , $ b ) ; return $ result === 0 ? $ keys [ $ a ] - $ keys [ $ b ] : $ result ; } ) ; return new static ( $ items ) ; }
Sort an array by keys using a user-defined comparison function.

@param callable $callback

@return static
Sort an array by keys using a user - defined comparison function .