public function arsort(int $option = SORT_REGULAR): Collection
    {
        $index = 0;
        $items = $this->items;

        foreach ($items as &$item) {
            $item = [$index++, $item];
        }

        uasort($items, function ($a, $b) use ($option) {
            if ($a[1] === $b[1]) {
                return $a[0] - $b[0];
            }

            $set = [-1 => $b[1], 1 => $a[1]];

            asort($set, $option);
            reset($set);

            return key($set);
        });

        foreach ($items as &$item) {
            $item = $item[1];
        }

        return new static($items);
    }
public function arsort(int $option = SORT_REGULAR): Collection
    {
        $index = 0;
        $items = $this->items;

        foreach ($items as &$item) {
            $item = [$index++, $item];
        }

        uasort($items, function ($a, $b) use ($option) {
            if ($a[1] === $b[1]) {
                return $a[0] - $b[0];
            }

            $set = [-1 => $b[1], 1 => $a[1]];

            asort($set, $option);
            reset($set);

            return key($set);
        });

        foreach ($items as &$item) {
            $item = $item[1];
        }

        return new static($items);
    }
public function arsort ( int $ option = SORT_REGULAR ) : Collection { $ index = 0 ; $ items = $ this -> items ; foreach ( $ items as & $ item ) { $ item = [ $ index ++ , $ item ] ; } uasort ( $ items , function ( $ a , $ b ) use ( $ option ) { if ( $ a [ 1 ] === $ b [ 1 ] ) { return $ a [ 0 ] - $ b [ 0 ] ; } $ set = [ - 1 => $ b [ 1 ] , 1 => $ a [ 1 ] ] ; asort ( $ set , $ option ) ; reset ( $ set ) ; return key ( $ set ) ; } ) ; foreach ( $ items as & $ item ) { $ item = $ item [ 1 ] ; } return new static ( $ items ) ; }
Sort an array in reverse order and maintain index association.

@param int $option

@return static
Sort an array in reverse order and maintain index association .