shuffle for associative arrays, preserves key=>value pairs.
http://www.php.net/manual/de/function.shuffle.php
762582
protected function shuffleAssoc(&$array) 
    {
        $keys = array_keys($array);
        shuffle($keys);
        shuffle($keys);
    
        foreach($keys as $key) 
        {
            $new[$key] = $array[$key];
            unset($array[$key]); /* save memory */
        }
        $array = $new;
        
        return true;
    }
1130337
function _shuffle(sample) {

	var shuffle = function shuffle(a, i, j) {
		sample(j - i, a, i, j);
	};

	return shuffle;
}
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;
    }
714194
public static void shuffle(long[] longArray) {
		int swapPlace = -1;

		for(int i = 0; i < longArray.length; i++) {
			swapPlace = (int) (Math.random() * (longArray.length - 1 ));
			XORSwap.swap(longArray, i, swapPlace);
		}
	}
1265958
private function recurArrayChange($array, $keyArray, $value = null)
    {
        $key0 = $keyArray[0];
        if (count($keyArray) === 1) {
            $this->changeValue($array, $key0, $value);
        } else if (is_array($array) && isset($keyArray[1])) {
            unset($keyArray[0]);
            $keyArray = array_values($keyArray);
            if (!isset($array[$key0])) {
                $array[$key0] = [];
            }
            $array[$key0] = $this->recurArrayChange($array[$key0], $keyArray, $value);
        } else {
            $this->changeValue($array, $key0, $value);
        }
        return $array;
    }
868693
function baseSampleSize(collection, n) {
      var array = values(collection);
      return shuffleSelf(array, baseClamp(n, 0, array.length));
    }
998626
private function shuffle()
    {
        if ($this->first) {
            $this->first = array_slice($this->words, 0, 8);
            $this->words = array_slice($this->words, 8);

            shuffle($this->words);

            $this->words = $this->first + $this->words;

            $this->first = false;
        } else {
            shuffle($this->words);
        }
    }
710355
private static void shuffle(int[] a) {
        Random rnd = ThreadLocalRandom.current();
        for (int i = a.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i + 1);
            int e = a[index];
            a[index] = a[i];
            a[i] = e;
        }
    }
476504
def shuffle(self):
        
        order = range(len(self))
        random.shuffle(order)
        for name, data in self.fields.items():
            reindexed = []
            for _, i in enumerate(order):
                reindexed.append(data[i])
            self.fields[name] = reindexed
        return self
253766
private function serializeArrayOrTable(array $array)
    {
        $assoc = false;
        $index = 0;
        $values = [];

        foreach ($array as $key => $value) {
            // We already know the array is associative, serialize both the key
            // and the value ...
            if ($assoc) {
                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                // Otherwise, if the key matches the index counter it is sequential,
                // only serialize the value ...
            } elseif ($key === $index++) {
                $values[] = $this->serializeField($value);

                // Otherwise, we've just discovered the array is NOT sequential,
                // Go back through the existing values and add the keys ...
            } else {
                foreach ($values as $k => $v) {
                    $values[$k] = $this->serializeShortString($k) . $v;
                }

                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                $assoc = true;
            }
        }

        return ($assoc ? 'F' : 'A') . $this->serializeByteArray(
                implode('', $values)
            );
    }
995531
function arraySampleSize(array, n) {
      return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
    }
389364
function shuffle(array) {
  const copy = [...array];
  let currentIndex = array.length;
  let temporaryValue;
  let randomIndex;

  // While there remain elements to shuffle...
  while (currentIndex !== 0) {
    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = copy[currentIndex];
    copy[currentIndex] = copy[randomIndex];
    copy[randomIndex] = temporaryValue;
  }

  return copy;
}
36740
public static function array_merge_recursive_unique($array1, $array2)
    {
        // LOOP THROUGH $array2
        foreach ($array2 as $k => $v) {

            // CHECK IF VALUE EXISTS IN $array1
            if (!empty($array1[$k])) {
                // IF VALUE EXISTS CHECK IF IT'S AN ARRAY OR A STRING
                if (!is_array($array2[$k])) {
                    // OVERWRITE IF IT'S A STRING
                    $array1[$k]=$array2[$k];
                } else {
                    // RECURSE IF IT'S AN ARRAY
                    $array1[$k] = self::array_merge_recursive_unique($array1[$k], $array2[$k]);
                }
            } else {
                // IF VALUE DOESN'T EXIST IN $array1 USE $array2 VALUE
                $array1[$k]=$v;
            }
        }
        unset($k, $v);

        return $array1;
    }
614652
function randomizeArray(array) {
  let i = array.length;
  while (i) {
    let j = Math.floor(Math.random() * i--);
    [array[i], array[j]] = [array[j], array[i]];
  }
  return array;
}
1101130
private function arrayIntersectRecursive($arr1, $arr2)
    {
        if (!is_array($arr1) || !is_array($arr2)) {
            return false;
        }
        // if it is not an associative array we do not compare keys
        if ($this->arrayIsSequential($arr1) && $this->arrayIsSequential($arr2)) {
            return $this->sequentialArrayIntersect($arr1, $arr2);
        }
        return $this->associativeArrayIntersect($arr1, $arr2);
    }
178634
public static <E> void shuffle(E[] array) {
		int swapPlace = -1;
		
		for(int i = 0; i < array.length; i++) {
            swapPlace = (int) (Math.random() * (array.length - 1 ));
            TrivialSwap.swap(array, i, swapPlace);
		}
	}
137779
public function shuffle()
    {
        $keys = $this->getKeys();
        shuffle($keys);

        return $this->createFrom(array_replace(array_flip($keys), $this->toArray()));
    }