public function shuffle(): Collection
    {
        // Get keys and shuffle
        $keys = array_keys($this->list);
        shuffle($keys);

        // Attribute shuffle keys to theirs values
        $newList = [];
        foreach ($keys as $key) {
            $newList[$key] = $this->list[$key];
        }

        // Update list
        $this->list = $newList;

        return $this;
    }
public function shuffle(): Collection
    {
        // Get keys and shuffle
        $keys = array_keys($this->list);
        shuffle($keys);

        // Attribute shuffle keys to theirs values
        $newList = [];
        foreach ($keys as $key) {
            $newList[$key] = $this->list[$key];
        }

        // Update list
        $this->list = $newList;

        return $this;
    }
public function shuffle ( ) : Collection { // Get keys and shuffle $ keys = array_keys ( $ this -> list ) ; shuffle ( $ keys ) ; // Attribute shuffle keys to theirs values $ newList = [ ] ; foreach ( $ keys as $ key ) { $ newList [ $ key ] = $ this -> list [ $ key ] ; } // Update list $ this -> list = $ newList ; return $ this ; }
Shuffle list and preserve keys.

@return static
Shuffle list and preserve keys .