public async Task <IEnumerable <Product> > SortAsync(IEnumerable <Product> products, SortDirection sortDirection) { //1. Retrieve shopper's histories var shopperHistories = await _shoppingRepository.GetShopperHistoriesAsync(); //2. Sort products by weightage return((from p in products let weightage = CalculateProductWeightage(p, shopperHistories) orderby weightage descending select p).ToList()); }