System.Collections.Generic.IEnumerable.OrderByRandom()

Here are the examples of the csharp api System.Collections.Generic.IEnumerable.OrderByRandom() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 Source : ExtensionMethods2.cs
with GNU General Public License v3.0
from hitchhiker

public static IEnumerable<T> TakeRandom<T>(this IEnumerable<T> items, int minimum, int percentageWin = 50)
        {
            var its = items.ToList();
            var t = its.Count();
            return t == 0 ? its : its.OrderByRandom().Where(i => minimum-- > 0 || Rnd.I.DiceRoll(percentageWin)).ToList();
        }