Shuffle list and preserve keys.

@return static
164432
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;
    }
721668
public function removeFromList()
    {
        if ( ! $this->isInList()) return $this;

        $this->decrementPositionsOfItemsBelow();
        $this->setListPosition(null);

        return $this;
    }
1224971
protected function _shuffle()
	{
		$keys = array_keys($this->_tagsArray);
		shuffle($keys);
		if (count($keys) && is_array($keys)) {
			$tmpArray = $this->_tagsArray;
			$this->_tagsArray = array();
			foreach ($keys as $key => $value)
				$this->_tagsArray[$value] = $tmpArray[$value];
		}
		return $this->_tagsArray;
	}
34960
public function shuffle() 
    {
        $shuffling = clone $this;
        $groups = $shuffling->getShufflingGroups();
        
        for ($i = 0; $i < count($groups); $i++) {
            $identifiers = $groups[$i]->getIdentifiers();
            $fixedIdentifiers = $groups[$i]->getFixedIdentifiers()->getArrayCopy();
            $shufflableIndexes = array();
            
            // Find shuffblable indexes.
            for ($n = 0; $n < count($identifiers); $n++) {
                if (in_array($identifiers[$n], $fixedIdentifiers) === false) {
                    $shufflableIndexes[] = $n;
                }
            }
            
            // Shuffle the new group.
            $n = count($shufflableIndexes) - 1;
            for ($j = $n; $j > 0; $j--) {
                $k = mt_rand(0, $n);
                
                $tmp1 = $identifiers[$shufflableIndexes[$j]];
                $tmp2 = $identifiers[$shufflableIndexes[$k]];
                
                $identifiers[$shufflableIndexes[$j]] = $tmp2;
                $identifiers[$shufflableIndexes[$k]] = $tmp1;
            }
        }
        
        return $shuffling;
    }
1202828
public function diff()
    {
        $result = [];

        foreach ($this->keys() as $key) {
            if ($diff = $this->equal($key)) {
                $result[] = $diff; continue;
            }

            if ($diff = $this->delete($key)) {
                $result[] = $diff;
            }

            if ($diff = $this->insert($key)) {
                $result[] = $diff;
            }
        }

        return $result;
    }
53489
public function random()
    {
        $objReturn = null;

        $intIndex = rand(0, (count($this->collection) - 1));
        if (isset($this->collection[$intIndex])) {
            $objReturn = $this->collection[$intIndex];
        }

        return $objReturn;
    }
964792
public function combineKeys(iterable $keys): self
    {
        if (count($keys) != count($this->items)) {
            $this->doThrow('Invalid input for combineKeys, number of items does not match.', $keys);
        }
        $collection = Factory::create();
        $this->rewind();
        foreach ($keys as $key) {
            $collection->set($key, $this->current());
            $this->next();
        }
        $this->rewind();

        return $collection;
    }
749715
function randomize_options( $options ) {
		$new  = array();
		$keys = array_keys( $options );
		shuffle( $keys );

		foreach ( $keys as $key ) {
			$new[ $key ] = $options[ $key ];
		}

		return $new;
	}
849908
protected function _toArrayWithoutPrimaryKeys()
    {
        $ret = $this->toArray();
        unset($ret[$this->getModel()->getPrimaryKey()]);
        foreach ($this->_getSiblingRows() as $r) {
            $primaryKey = $r->getModel()->getPrimaryKey();
            if ($primaryKey) {
                unset($ret[$primaryKey]);
            }
        }
        return $ret;
    }
226897
public function shuffle()
    {
        $keys = $this->getKeys();
        shuffle($keys);

        return $this->createFrom(array_replace(array_flip($keys), $this->entries));
    }
501399
def shuffle(self):
        

        args = list(self)
        random.shuffle(args)

        self.clear()
        super(DogeDeque, self).__init__(args)
1147507
public function multiple(): self
    {
        $unique_array = array_unique($this->getArrayCopy());
        return new ArrayMap(array_diff_assoc($this->getArrayCopy(), $unique_array));
    }
1077425
public function rand(){
		if($this->validateConditions())
			return $this;

		$this->resetState();
		$this->connection->getDriver()->randomizeOrder($this);
		return $this;
	}
264873
public function shuffle($collection=null) {
    list($collection) = self::_wrapArgs(func_get_args(), 1);
    
    $collection = (array) self::_collection($collection);
    shuffle($collection);
     
    return self::_wrap($collection);
  }
795489
public function randomize() : self
    {
        $order = range(0, $this->numRows() - 1);

        shuffle($order);

        array_multisort($order, $this->samples, $this->labels);

        return $this;
    }
164216
public function natcasesort(): Collection
    {
        $index = 0;
        $items = $this->items;

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

        uasort($items, function ($a, $b) {
            $result = strnatcasecmp($a[1], $b[1]);

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

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

        return new static($items);
    }
1077468
def shuffle
      return self.class.new(((array = to_a).frozen? ? array.shuffle : array.shuffle!).freeze)
    end