in reply to comparing two sets of data

To expand a little on what CountZero said, It's not entirely clear what you're trying to do, but since you already started working on this, you could make it easier to help you if you did a few things:

If you wrap it all in <code> tags it will be easy to read and you'll probably get one or more solutions pretty quickly.