I have a tuple dataframe
of multiple data types
public static void Main(string[] args) {
int[] a = { 1, 0, 3, 4, 0};
int[] b = { 3, 0, 9, 10, 0};
int[] c = { 2, 3, 3, 5, 0};
var ret = new Dictionary<string, int[]>();
ret.Add("Jack", a);
ret.Add("Jane", b);
ret.Add("James", c);
var dataframe = new Tuple<string[], Dictionary<string, int[]>, string[]>(
new string[] { "Game 1", "Game 2", "Game 3", "Game 4", "Game 5" },
ret,
new string[] { "A", "B", "C", "B", "A" }
);
The values in dataframe.item1
and dataframe.item3
are different labels for the columns in dictionary in dataframe.item2
.
I want to sort items in the tuple including the order of arrays in the dictionary alphabetically by dataframe.item3
.
So dataframe.item3
would be {"A","A","B","B","C"}
dataframe.item1
would be {"Game 1","Game 5","Game 2","Game 4","Game 3"}
dataframe.item2["Jack"]
would be {1, 0, 0, 4, 3}
Here is what I tried
//Sorting the dictionary
Dictionary<string, int[]> sortedDict = new Dictionary<string, int[]>();
for each (var item in dataframe.Item2)
{
Array.Sort(dataframe.Item3,dataframe.Item2[item])
}
//Sorting the strings and creating a new dataframe
var sorted_dataframe = new Tuple<string[], Dictionary<string, int[]>, string[]>(
Array.Sort(dataframe.Item3, dataframe.Item1),
sortedDict,
Array.Sort(dataframe.Item3)
);