public void Linq008() { var comp = new ProductPriceComparer(); var query = dataSource.Products.GroupBy(p => p.UnitPrice, comp); foreach (var priceCategory in query) { Console.WriteLine(ProductPriceHelper.GetPriceCategory(priceCategory.Key)); foreach (var product in priceCategory) { Console.Write(" - "); ObjectDumper.Write(product); } } }
public void sortProductsByPrice() { ProductPriceComparer comparer = new ProductPriceComparer(); products.Sort(comparer); }