My structures are defined like this:
List<int> Column = new List<int>();
List<List<int>> Columns = new List<List<int>>();
I'm populating the structure like this:
Columns.Clear();
for (int x=0;...
{
Column.Clear();
Column.Add(0); // amount of adjustment for this list
Column.Add(x);
for (int y=0;...
...
Column.Add(data);
Column[0] += dataAdjustment; // keep running total of adjustment
}
Columns.Add(Column);
}
Then, I'm trying to get the data out like this:
Columns.Sort((r1, r2) => r1[0].CompareTo(r2[0]));
Column = Columns[0];
I only want the column with the least amount of adjustment.
My problem is that in the end, Column always has in it the last column added to the list of columns and not the column with the least amount of adjustment.
What am I doing wrong? How can I get the list with the least amount of adjustment running total?