Z
Z
Zefirot2021-10-25 16:10:31
C++ / C#
Zefirot, 2021-10-25 16:10:31

How to shuffle a dictionary of objects?

I thought there was some method like .Suffle() but no, tell me how to shuffle a Dictionary type dictionary so that the pairs are preserved but the order is different?
int out of order, a collection of different non-repeating digits (1,5,7,8,15,18, etc.)...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AndromedaStar, 2021-10-25
@Zefirot

Random rand = new Random();
var shuffledDictionary = originalDictionary.OrderBy(x => rand.Next()).ToDictionary(item => item.Key, item => item.Value);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question