IS there any way to emulate the behavior of Collections.shuffle without a comparator being vulnerable to the sorting algorithm implementation for the result to be safe?
A bit more generic to the previous answer, when the type of element is not known:
public static Comparator shuffle() {
final Map
can be used in streams as well:
list.stream().sorted(Streams.shuffle()).collect(Collectors.toList())
there might be collisions somehow, so it can be extended using a HashSet
for the UUID
to check this case