private async Task <List <ProductWithQuantity> > SortByPopularity() { var shopperHistories = await _apiCaller.GetShopperHistory(); var productPopularity = GenerateProductPopularity(shopperHistories); var _products = await _apiCaller.GetProducts(); _products.Sort((x, y) => { return(productPopularity.TryGetValue(y.Name).CompareTo(productPopularity.TryGetValue(x.Name))); }); return(_products); }