static <T> Seq<T> shuffle(Seq<? extends T> stream, Random random) {
        Spliterator<? extends T>[] shuffled = new Spliterator[1];

        // [#323] Some explicit type variable bindings required because of compiler regressions in JDK 9
        return SeqUtils.<T, T>transform(stream, (delegate, action) -> {
            if (shuffled[0] == null) {
                List<T> list = Seq.<T>seq(delegate).toList();
                
                if (random == null)
                    Collections.shuffle(list);
                else
                    Collections.shuffle(list, random);
                
                shuffled[0] = list.spliterator();
            }

            return shuffled[0].tryAdvance(action);
        }).onClose(stream::close);
    }
Shuffle a stream using specified source of randomness
<p>
<pre><code>
// e.g. (2, 3, 1)
Seq.of(1, 2, 3).shuffle(new Random())
</code></pre>
jOOL/src/main/java/org/jooq/lambda/Seq.java