The title suggests that i\'ve already an idea what\'s going on, but i cannot explain it. I\'ve tried to order a List dynamically by each \"colum
This is probably happening because the value of i is not closed within the loop - when the loop exits, i will have a value of 2 and then t[i] will be evaluated because of deferred execution.
One solution is to create a closing variable within the loop:
int minDim = someValues.Min(t => t.GetLength(0)); // 2
IOrderedEnumerable orderedValues = someValues.OrderBy(t => t[0]);
for (int i = 1; i < minDim; i++)
{
var x = i;
orderedValues = orderedValues.ThenBy(t => t[x]);
}
someValues = orderedValues.ToList();