Pass one piece of the array at a time. That way the inner loop only has to do one thing with one item at a time.