2

我想出的是:

RandomSort()
{
  string[] list = { "Alpha", "Beta", "Gamma", ... }
  Random rnd = new Random();
  string[] list2 = list.OrderBy((x) => rnd.NextDouble()).ToArray();
}

有没有其他方法,也许使用 aDictionary或什么?谢谢。

4

1 回答 1

6

这当然很简单,但它是 O(n log(n))。通过使用Fisher Yates shuffle ,您可以在性能方面做得更好。

于 2011-01-30T01:04:49.700 回答