Not sure if there is an algorithm to describe this problem, but are there any nifty methods for combining a list in a user-defined sequence. For instance:
List<string> list1 = new List<string>();
List<string> list2 = new List<string>();
List<string> list3 = new List<string>();
list1.Add("a");
list1.Add("b");
list1.Add("c");
list2.Add("d");
list2.Add("e");
list2.Add("f");
list3.Add("g");
list3.Add("h");
list3.Add("i");
List<string> combined = new List<string>();
I would like the contents of the combination to contain the following sequence:
a //First record in list1
d //First record in list2
g //First record in list3
b //Second record in list1
e //Second record in list2
h //Second record in list3
c //Third record in list1
f //Third record in list2
i //Third record in list3
The number of entries in each list may not be equal.
EDIT
When the number of entries in each list may not be equal, I mean:
List<string> list1 = new List<string>();
List<string> list2 = new List<string>();
List<string> list3 = new List<string>();
list1.Add("a");
list2.Add("b");
list2.Add("c");
list3.Add("d");
list3.Add("e");
list3.Add("f");
List<string> combined = new List<string>();
Expected results:
a //First record in list1
b //First record in list2
d //First record in list3
c //Second record in list2
e //Second record in list3
f //Third record in list3
source
share