Program.cs 843 B

123456789101112131415161718192021222324252627282930
  1. using Masuit.Tools.RandomSelector;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace Test
  6. {
  7. static class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var result = new List<string>();
  12. for (int i = 0; i < 1000; i++)
  13. {
  14. result.Add(new List<WeightedItem<string>>()
  15. {
  16. new WeightedItem<string>("A", 1),
  17. new WeightedItem<string>("B", 3),
  18. new WeightedItem<string>("C", 4),
  19. new WeightedItem<string>("D", 4),
  20. }.WeightedItem());
  21. }
  22. foreach (var g in result.GroupBy(s => s).OrderByDescending(g => g.Count()))
  23. {
  24. Console.WriteLine(g.Key + ":" + g.Count());
  25. }
  26. }
  27. }
  28. }