I am trying to figure out how to sort through an array based on a column value and I'm having a hard time figuring out how to do it. For example in the following code I might want to be able to search for something like this.
If the first element of the row = 1 and the second element of the row = 1 and the third element of the row = 2, abs(fourth element) = abs(fourth element) from each of the other rows. I know that might have been kind of confusing.
Basically I want to be able to say if I know that certain row elements are equal to something that I'm looking for I want to be able to find each case of that and then be able to check for the equality of a specific element from that row.
// Constraint Parameters are (tableID,tupleID,constraintID,bound,isEqual,unNormalized).
public Constraints [] c = new Constraints[8];
public void cinit()
{
//Zero Tuple
c [0] = new Constraints (1,0,0,0,true,false);// first constraint
c [1] = new Constraints (1,0,1,-24000,false,false);// second constraint
c [2] = new Constraints (1,0,2,0,true,false);// third constraint
c [3] = new Constraints (1,0,3,0,true,false);// fourth constraint
//First Tuple
c [4] = new Constraints (1,1,0,2400,false,false);// first constraint
c [5] = new Constraints (1,1,1,-58150,false,false);// second constraint
c [6] = new Constraints (1,1,2,-6370,true,false);// third constraint
c [7] = new Constraints (1,1,3,6370,true,false);// fourth constraint
}
I'm getting really mixed up trying to sort this out. I know I want to have a series of nested for loops to but I'm not quite sure how to do it.
c.Where(x => x.tableID==1)
– I4V Apr 26 '13 at 15:51