I have an array of hex numbers, and I need to go over other numbers and check if they appear in that array. Right now i\'m using a foreach loop that goes over t
If you're just going to do one search, then sorting will take longer than performing a single linear scan, so you may as well just stick with looping over the array. For a small array, or if you could have multiple matches, you might also want to look at the grep function; it's a little easier to use, but it will always check the entire list of candidate matches instead of stopping when a match is found.
If you're going to be searching many times, putting the array's values into a hash and doing hash lookups will be faster than searching the array, even if you sort it and do a binary search (assuming you can afford the memory cost, but you almost certainly can).