i need your help on this one.
lets say:
public class myProduct
{
public string Tags {get;set;} // Comma seperated values
}
List<myProduct> myProducts = WhatEver // Feeding the list products
List<long> capacity = WhatEverAlso // Feed the list long values from somewhere
now, what i want to do is order the myProducts list by capacity.
so , if a myProduct.Tags = “89,3,6”
and capacity = “1,2,3,4,5,6”
first will appear products with 1 in them, then 2 etc.
the problem is not ordering them, the problem actually is that some Tags do not contain capacity values.
EDIT:
for example, a products.tags could be “89,16,99”
so it does not contain any of the capacity values.
EDIT2:
I do not need to filter the products, just to order them.
EDIT3:
i started to with var foo = myProducts.OrderBy(p => p.Tags.Split(',').Intersect(capacity).OrderBy(c => capacity).Any());
and i feel that im close, but i cant figure out the rest. 🙁
hope you understood my question, my expression in english is not that good :\
feel free to ask me for any additional information.
The question isn’t entirely clear, but does this get you on the right track?
This orders the products by the earliest location of any of its tags in the
capacitylist. If none of its tags are in thecapacitylist, a product is not included in the final results.