in reply to search array for closest lower and higher number from another array

Thinking completely outside of the box here... what about SQLite?   This will put your data “in a single file” (no database servers required), but also to allow you to index it, and to retrieve the data you’re looking for by means of SQL queries.   I can tell you from plentious experience that this engine is blisteringly fast, it runs on absolutely everything, and it can lift a lot of work completely off your shoulders.   If you find yourself trying to cobble up an algorithm to do something (as in this case), perhaps step back and see if a fundamentally different approach like this one might be better.   Perchance, much better...

Replies are listed 'Best First'.
Re^2: search array for closest lower and higher number from another array
by bigbot (Beadle) on Feb 08, 2011 at 01:28 UTC
    That sounds really useful. I'm not sure if I can use it at work, but certainly worth looking at. Thanks.