My OM has a 'product' object.
Each product has a 'manufacturer id' (property, integer).
When I have a list of products to display, the first three are displayed as the 'featured products'.
The list is already sorted in a specific sort order, putting the 'featured' products first in the list.
However, I now need to ensure the featured products in the listing are from different Manufacturers. I want to have a method to call to do this re-sorting. Trying to utilize LINQ to to the querying of the input 'products' and the 'results'
public List<Product> SetFeatures(List<Product> products, int numberOfFeatures)
{
List<Product> result;
// ensure the 2nd product is different manufacturer than the first ....
// ensure the 3rd product is a different manufacturer than the first two...
// ... etc ... for the numberOfFeatures
return result;
}
Thanks in advance.
Clarification:
The original list is in a specific order: the 'best selling', highest first (descending order). The resulting list should remain in this order with the exception of adjusting or moving 'up' items so that the differing manufacturers are seen the top n features.
If the first n (numberOfFeatures) of items all have different manufacturers, then the listing does not need to be altered at all.
e.g. If numberOfFeatures = 3
Product 1 - Manufacturer A (1st feature)
Product 2 - Manufacturer B (2nd feature)
Product 3 - Manufacturer C (3rd feature)
Product 4 - Manufacturer A (...not checked...)
Product 5 - Manufacturer A (...not checked...)
e.g. Case to adjust ... for example ...
INPUT List
Product 1 - Manufacturer A
Product 2 - Manufacturer A
Product 3 - Manufacturer B
Product 4 - Manufacturer A
Product 5 - Manufacturer F
(... we would want ...)
Product 1 - Manufacturer A (1st feature)
Product 3 - Manufacturer B (2nd feature ... moved up)
Product 5 - Manufacturer F (3rd feature ... moved up)
Product 2 - Manufacturer A (...pushed down the list...)
Product 4 - Manufacturer A (...pushed down the list...)