I am trying to make an extension method and am having some difficulty with this case, examples:
IEnumerable<string> list1 = // { "A", "B", "C" }
IEnumerable<string> list2 = // { "B", "D" }
IEnumerable<string> list3 = // { "D", "A", "C". "B" }
list1.OrderByEnumerable(list3) -> // { "A", "C", "B" }
list2.OrderByEnumerable(list3) -> // { "D", "B" }
I have been trying something along the lines of:
static IEnumerable<T> OrderByEnumerable<T>(this IEnumerable<T> data, IEnumerable<string> data2)
{
return data.Zip(data2, (x, y) => //
}
but I quickly realized I need some way to iterate through the enumerables to find out of I need to "skip" a value and somehow. Any ideas or pointers in the right direction?