Writing a linear search is of course the worst way to do it. As your array is sorted you can use something like qBinaryFind/qUpperBound/qLowerBound that brings it down to logarithmic order. Even better is introducing a hash tab where you would have a constant order.
Simply doing what we all learned in school.
Uwe
Bookmarks