Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想出的是:
RandomSort() { string[] list = { "Alpha", "Beta", "Gamma", ... } Random rnd = new Random(); string[] list2 = list.OrderBy((x) => rnd.NextDouble()).ToArray(); }
有没有其他方法,也许使用 aDictionary或什么?谢谢。
Dictionary
这当然很简单,但它是 O(n log(n))。通过使用Fisher Yates shuffle ,您可以在性能方面做得更好。