// make sure to sort the records correctly
        // 1st: items with a coupon applied
        // 2nd: catalog items
        // 3rd: order
        // 4th: shipping
        private PromotionRecord[] SortPromotionRecords(PromotionRecord[] records)
        {
            var all = new List<PromotionRecord>();
            var recordsWithCoupons = from r in records where !String.IsNullOrEmpty(r.Reward.Promotion.CouponId) orderby r.Reward.Promotion.Priority descending select r;

            // all all coupon records first
            all.Add(recordsWithCoupons);

            var catalogRecords = from r in records where r.PromotionType == PromotionType.CatalogPromotion && !all.Contains(r) orderby r.Reward.Promotion.Priority descending select r;
            all.Add(catalogRecords);

            var cartRecords = from r in records where r.PromotionType == PromotionType.CartPromotion && !all.Contains(r) orderby r.Reward.Promotion.Priority descending select r;
            all.Add(cartRecords);

            return all.ToArray();
        }
		private LineItem[] GetLineItemsSuitableForCatalogItemReward(PromotionRecord record)
		{
			var reward = record.Reward as CatalogItemReward;
			if (reward == null)
			{
				return new LineItem[0];
			}
			var entries = record.AffectedEntriesSet.Entries.ExcludeCategories(ParseStringIds(reward.ExcludingCategories))
								.ExcludeProducts(ParseStringIds(reward.ExcludingProducts))
								.ExcludeSkus(ParseStringIds(reward.ExcludingSkus))
								.InCategory(reward.CategoryId)
								.InProduct(reward.ProductId)
								.OfSku(reward.SkuId)
								.ToArray();

			var ids = from e in entries select e.EntryId;
			return (from l in CurrentOrderGroup.OrderForms[0].LineItems
					where ids.Contains(l.CatalogItemId, StringComparer.OrdinalIgnoreCase)
					select l).ToArray();
		}
	    public PromotionRecord[] EvaluatePolicies(PromotionRecord[] records, IEvaluationPolicy[] policies = null)
	    {
	        policies = policies ?? _policies;
			records = SortPromotionRecords(records);
			return policies.Aggregate(records, (current, policy) => policy.FilterPromotions(null, current));
	    }