in reply to Efficiently compare sorted array vs another sorted array and pattern match

There's no "outer loop". This is like the merge in mergesort. You look at the first element of the array and of the file. If they're equal, you do your thing and advance them both. Otherwise, you advance the smaller one and repeat.

Caution: Contents may have been coded under pressure.
  • Comment on Re: Efficiently compare sorted array vs another sorted array and pattern match