using Masuit.Tools.RandomSelector; using System.Collections.Generic; using System.Linq; namespace Masuit.Tools { public static partial class Extensions { public static int TotalWeight(this WeightedSelector selector) { return selector.Items.Count == 0 ? 0 : selector.Items.Sum(t => t.Weight); } public static List> OrderByWeightDescending(this WeightedSelector selector) { return selector.Items.OrderByDescending(item => item.Weight).ToList(); } public static List> OrderByWeightAscending(this WeightedSelector selector) { return selector.Items.OrderBy(item => item.Weight).ToList(); } public static T WeightedItem(this IEnumerable> list) { return new WeightedSelector(list).Select(); } public static List WeightedItems(this IEnumerable> list, int count) { return new WeightedSelector(list).SelectMultiple(count); } } }