jacobemerick / shuffle_slightly
v1.0.0
2014-07-01 13:34 UTC
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2024-11-05 07:56:51 UTC
README
Function to slightly shuffle an array based on a tolerance parameter.
There may come a time when you want to shuffle an array but you don't want to completely ignore the order. This function, which behaves much like the native shuffle, will perform a slight shuffle.
For example, if you want to shuffle a simple array but you don't want to move any elements more than 2 positions away from their start, just do this.
$array = ['a', 'b', 'c', 'd', 'e']; jacobemerick\shuffle_slightly($array, 2);
Installation
Through composer:
$ composer require jacobemerick/shuffle_slightly:~1.0
More Information
I wrote a blog post talking about the reasoning, build, and some extra information about shuffling algorithms.