How to match values?

Hi All,

So I have a bunch of waves with the following data,

XValues YValues NumLevelCrossing

Now the first column basically is the X, and the second is the Yvalues. The third column basically denotes the number of times a particular Y-value is crossed. The second time the curve goes through the Yvalue = 1 occurs at Xvalue = 10.

For example, the waves have been compiled into one table in the following manner.

XValue = 4, Yvalue = 1, NumLevel Crossing = 2
.
.
.
Xvalue = 10, Yvalue = 1, NumLevel Crossing = 2

I need to find out for each yvalue, with its corresponding number of level crossings, at what x-value the crossings occur.
I was thinking that I could do this via FindLevels, but such a function does not present those values. In other words, I have to sort through the data to do this, and I was wondering if any one could give me some tips on what I could use.

I was thinking of matching up the indices for each of the necessary elements but it doesn't seem to work. The original code that has been written to find the NumLevelCrossing is given below, with the necessary changes I tried to implement for the stuff above in comments.

 
for(i=0; i<numPoints; i+=1)
   FindLevels ... //So here I basically implemented the finidlevels to find the number of level crossings
   Variable NumLevelCross = V_LevelsFound
   NumLevelCrossing[count0] = NumLevelCross
 
//for(j=0;j<numPoints2; j+=1)
     //Variable NumLevelCrossLoc = i
     //if(NumLevelCrossLoc==j)
        //Variable Xvalue = sortwave2[i]
       //count1 += 1
    //endif
//endfor

//Basically what I have done above is to take the index of the counter i which goes through y-values
//and then said that if it is equated with the x-value index j then we have the Xvalue given by sortwave[i]
//But this doesn't seem to work.

   print NumLevelCross
   count0 += 1
endfor
   Redimension /N=(count0) NumLevelCross
End